Ignore:
Timestamp:
Aug 28, 2015, 10:12:22 AM (9 years ago)
Author:
gah
Message:

merge accumulative changes from 1.3 branch into uq branch

Location:
branches/uq
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/uq

  • branches/uq/src/core/RpDict.h

    r5679 r5850  
    2222/**************************************************************************/
    2323
    24 template <  typename KeyType,
    25             typename ValType,
    26             class _Compare=std::equal_to<KeyType> >
     24template <typename KeyType,
     25          typename ValType,
     26          class _Compare=std::equal_to<KeyType> >
    2727    class RpDict;
    2828
    29 template <  typename KeyType,
    30             typename ValType,
    31             class _Compare=std::equal_to<KeyType> >
     29template <typename KeyType,
     30          typename ValType,
     31          class _Compare=std::equal_to<KeyType> >
    3232    class RpDictEntry;
    3333
    34 template <  typename KeyType,
    35             typename ValType,
    36             class _Compare=std::equal_to<KeyType> >
     34template <typename KeyType,
     35          typename ValType,
     36          class _Compare=std::equal_to<KeyType> >
    3737    class RpDictIterator;
    38 
    3938
    4039/*
     
    4847 * because RpBindingsDict uses it.
    4948 */
    50 
    5149
    5250/**************************************************************************/
     
    9391    private:
    9492
    95         RpDict<KeyType,ValType,_Compare>& 
    96             tablePtr;                   /* pointer to the table we want to 
     93        RpDict<KeyType,ValType,_Compare>&
     94            tablePtr;                   /* pointer to the table we want to
    9795                                         * iterate */
    9896        int srchNextIndex;              /* Index of next bucket to be
    9997                                         * enumerated after present one. */
    100         RpDictEntry<KeyType,ValType,_Compare>* 
     98        RpDictEntry<KeyType,ValType,_Compare>*
    10199            srchNextEntryPtr;           /* Next entry to be enumerated in the
    102100                                         * the current bucket. */
    103101
    104102};
    105 
    106103
    107104template <typename KeyType, typename ValType, class _Compare>
     
    113110        // operator==(const RpDictEntry& entry) const;
    114111        //
    115         //operator!=(const RpDictEntry& lhs, const RpDictEntry& rhs) const 
     112        //operator!=(const RpDictEntry& lhs, const RpDictEntry& rhs) const
    116113        //{
    117114        //    if (lhs.key != rhs.key)
     
    189186};
    190187
    191 
    192188template <typename KeyType, typename ValType, class _Compare>
    193189class RpDict
     
    207203        //
    208204        /*virtual*/ RpDict<KeyType,ValType,_Compare>&
    209                         set(    KeyType& key,
    210                                 ValType& value,
    211                                 RpDictHint hint=NULL,
    212                                 int *newPtr=NULL,
    213                                 bool ci=false);
     205                        set(KeyType& key,
     206                            ValType& value,
     207                            RpDictHint hint=NULL,
     208                            int *newPtr=NULL,
     209                            bool ci=false);
    214210
    215211        // find an RpUnits object that should exist in RpUnitsTable
    216         // 
     212        //
    217213        /*virtual*/ RpDictEntry<KeyType,ValType,_Compare>&
    218                         find(   KeyType& key,
    219                                 RpDictHint hint = NULL,
    220                                 bool ci=false   );
    221 
    222         /*virtual*/ RpDictEntry<KeyType,ValType,_Compare>& operator[]( KeyType& key)
     214                        find(KeyType& key,
     215                             RpDictHint hint = NULL,
     216                             bool ci=false);
     217
     218        /*virtual*/ RpDictEntry<KeyType,ValType,_Compare>& operator[](KeyType& key)
    223219        {
    224220            return find(key,NULL);
    225221        }
    226222
    227         RpDict<KeyType,ValType,_Compare>& setCI( bool val );
     223        RpDict<KeyType,ValType,_Compare>& setCI(bool val);
    228224        bool getCI();
    229225        RpDict<KeyType,ValType,_Compare>& toggleCI();
     
    263259        }
    264260
    265         // copy constructor 
     261        // copy constructor
    266262        // RpDict (const RpDict& dict);
    267263
     
    283279        const int REBUILD_MULTIPLIER;
    284280
    285         RpDictEntry<KeyType,ValType,_Compare> 
     281        RpDictEntry<KeyType,ValType,_Compare>
    286282                    **buckets;        /* Pointer to bucket array.  Each
    287283                                       * element points to first entry in
     
    314310
    315311        RpDictEntry<KeyType,ValType,_Compare>*
    316             search( KeyType& key, RpDictHint hint = NULL, bool ci = false );
     312            search(KeyType& key, RpDictHint hint = NULL, bool ci = false);
    317313
    318314        // static void RpDict::RebuildTable ();
     
    326322};
    327323
    328 
    329324/*--------------------------------------------------------------------------*/
    330325/*--------------------------------------------------------------------------*/
     
    340335 * Side Effects:
    341336 *  none.
    342  * 
     337 *
    343338 *
    344339 *************************************************************************/
    345 
    346340template <typename KeyType, typename ValType, class _Compare>
    347341int
     
    350344    return numEntries;
    351345}
    352 
    353346
    354347/**************************************************************************
     
    359352 *
    360353 * Results:
    361  *  Returns a reference to the RpDict object allowing the user to chain 
     354 *  Returns a reference to the RpDict object allowing the user to chain
    362355 *  together different commands such as
    363356 *      rpdict_obj.set(key).find(a).erase(a);
     
    370363template <typename KeyType, typename ValType, class _Compare>
    371364RpDict<KeyType,ValType,_Compare>&
    372 RpDict<KeyType,ValType,_Compare>::set(  KeyType& key,
    373                                         ValType& value,
    374                                         RpDictHint hint,
    375                                         int* newPtr,
    376                                         bool ci )
     365RpDict<KeyType,ValType,_Compare>::set(KeyType& key,
     366                                      ValType& value,
     367                                      RpDictHint hint,
     368                                      int* newPtr,
     369                                      bool ci)
    377370{
    378371    RpDictEntry<KeyType,ValType,_Compare> *hPtr = NULL;
     
    466459 *----------------------------------------------------------------------
    467460 */
    468 
    469461template <typename KeyType, typename ValType, class _Compare>
    470462RpDictEntry<KeyType,ValType,_Compare>&
    471 RpDict<KeyType,ValType,_Compare>::find( KeyType& key,
    472                                         RpDictHint hint,
    473                                         bool ci )
     463RpDict<KeyType,ValType,_Compare>::find(KeyType& key,
     464                                       RpDictHint hint,
     465                                       bool ci)
    474466{
    475467    RpDictEntry<KeyType,ValType,_Compare> *hPtr = NULL;
     
    503495 *----------------------------------------------------------------------
    504496 */
    505 
    506497template <typename KeyType, typename ValType, class _Compare>
    507498RpDictEntry<KeyType,ValType,_Compare>*
    508 RpDict<KeyType,ValType,_Compare>::search(   KeyType& key,
    509                                             RpDictHint hint,
    510                                             bool ci )
    511                                             // bool ci,
    512                                             // RpDictEntryList* entryList)
     499RpDict<KeyType,ValType,_Compare>::search(KeyType& key,
     500                                         RpDictHint hint,
     501                                         bool ci)
     502                                         // bool ci,
     503                                         // RpDictEntryList* entryList)
    513504{
    514505    RpDictEntry<KeyType,ValType,_Compare> *hPtr = NULL;
     
    572563}
    573564
    574 
    575 
    576565/**************************************************************************
    577566 *
     
    589578/*
    590579template <typename KeyType,typename ValType,class _Compare>
    591 RpDict<KeyType,ValType,_Compare>& 
    592 RpDictIterator<KeyType,ValType,_Compare>::getTable() 
     580RpDict<KeyType,ValType,_Compare>&
     581RpDictIterator<KeyType,ValType,_Compare>::getTable()
    593582{
    594583    return tablePtr;
     
    606595 * Side Effects:
    607596 *  moves iterator to the beginning of the hash table.
    608  * 
     597 *
    609598 *
    610599 *************************************************************************/
     
    630619 * Side Effects:
    631620 *  moves iterator to the next entry of the hash table if it exists.
    632  * 
     621 *
    633622 *
    634623 *************************************************************************/
    635 
    636624template <typename KeyType,typename ValType,class _Compare>
    637625RpDictEntry<KeyType,ValType,_Compare>*
     
    669657template <typename KeyType, typename ValType, class _Compare>
    670658RpDict<KeyType,ValType,_Compare>&
    671 RpDict<KeyType,ValType,_Compare>::setCI( bool val )
     659RpDict<KeyType,ValType,_Compare>::setCI(bool val)
    672660{
    673661    caseInsensitive = val;
     
    764752    return *nullEntry;
    765753}
    766 
    767754
    768755/*
     
    784771 *----------------------------------------------------------------------
    785772 */
    786 
    787773template <typename KeyType, typename ValType, class _Compare>
    788774void
     
    794780
    795781    // check to see if the object is associated with a table
    796     // if object is not associated with a table, there is no 
     782    // if object is not associated with a table, there is no
    797783    // need to try to remove it from the table.
    798784    if (tablePtr) {
     
    804790
    805791        // remove the entry from the buckets
    806         // 
     792        //
    807793        // if entry is the first entry in the bucket
    808794        // move the bucket to point to the next entry
     
    812798        else {
    813799            // if the entry is not the first entry in the bucket
    814             // search for the entry 
     800            // search for the entry
    815801            for (prevPtr = *bucketPtr; ; prevPtr = prevPtr->nextPtr) {
    816802
     
    821807                    prevPtr->nextPtr = nextPtr;
    822808                    break;
    823                 } 
     809                }
    824810            } // end for loop
    825811        } // end else
     
    843829}
    844830
    845 
    846831/*
    847832 *----------------------------------------------------------------------
     
    859844 *----------------------------------------------------------------------
    860845 */
    861 
    862846template <typename KeyType, typename ValType, class _Compare>
    863847const KeyType*
     
    884868 *----------------------------------------------------------------------
    885869 */
    886 
    887870template <typename KeyType, typename ValType, class _Compare>
    888871const ValType*
     
    907890 *----------------------------------------------------------------------
    908891 */
    909 
    910892template <typename KeyType, typename ValType, class _Compare>
    911893const ValType*
     
    944926 *----------------------------------------------------------------------
    945927 */
    946 
    947928template <typename KeyType, typename ValType, class _Compare>
    948929bool
     
    954935    return false;
    955936}
    956 
    957937
    958938/*************************************************************************/
     
    978958 *----------------------------------------------------------------------
    979959 */
    980 
    981960template <typename KeyType, typename ValType, class _Compare>
    982961void
    983962RpDict<KeyType,ValType,_Compare>::RebuildTable()
    984963{
    985     int oldSize=0, count=0, index=0; 
     964    int oldSize=0, count=0, index=0;
    986965    RpDictEntry<KeyType,ValType,_Compare> **oldBuckets = NULL;
    987966    RpDictEntry<KeyType,ValType,_Compare> **oldChainPtr = NULL, **newChainPtr = NULL;
     
    996975     */
    997976
    998 
    999977    numBuckets *= 4;
    1000978
     
    10541032 *----------------------------------------------------------------------
    10551033 */
    1056 
    10571034template <typename KeyType, typename ValType, class _Compare>
    10581035unsigned int
     
    10821059 * I chose the one below (multiply by 9 and add new character)
    10831060 * because of the following reasons:
    1084  * 
     1061 *
    10851062 * 1. Multiplying by 10 is perfect for keys that are decimal strings,
    10861063 *    and multiplying by 9 is just about as good.
     
    10911068 *    works well both for decimal and non-decimal strings.
    10921069 */
    1093 
    1094 
    10951070template <typename KeyType, typename ValType, class _Compare>
    10961071unsigned int
     
    11581133 * ---------------------------------------------------------------------
    11591134 */
    1160 
    11611135template <typename KeyType, typename ValType, class _Compare>
    11621136int
     
    11661140}
    11671141
    1168 
    1169 
    11701142#endif
Note: See TracChangeset for help on using the changeset viewer.