Exemplo n.º 1
0
/*
 * Insert a pair into a bucket (the bucket list is ordered by hashcode).
 */
void UtlHashMap::insert(UtlPair*       pair,  ///< The UtlPair for the entry if it was found.
                        UtlChain*      bucket ///< The bucket list header where the entry belongs.
                        )
{
   UtlPair* position;
   
   for (position = static_cast<UtlPair*>(bucket->listHead());
        (   position                     // not end of list
         && pair->hash <= position->hash // hash list is ordered, so if > then we're done.
         );
        position = static_cast<UtlPair*>(position->UtlChain::next)
        )
   {
   }
   /*
    * At this point, position is either:
    *  - NULL, in which case pair goes on the tail of the bucket
    *  - non-NULL in which case pair goes before position
    *
    * NOTE - it is an unchecked error if pair->data->isEqual(position->data)
    *        the caller must ensure this is not the case.
    */
   pair->UtlChain::listBefore(bucket, position);

   resizeIfNeededAndSafe();
}
Exemplo n.º 2
0
/*
 * Insert a link into a bucket (the bucket list is ordered by hashcode).
 */
void UtlHashBag::insert(UtlLink*       link,  ///< The UtlLink for the entry if it was found.
                        UtlChain*      bucket ///< The bucket list header where the entry belongs.
                        )
{
   UtlLink* inBucket;

   for (inBucket = static_cast<UtlLink*>(bucket->listHead());
        (   inBucket                     // not end of list
         && link->hash > inBucket->hash  // hash list is ordered, so if > then we're done.
         );
        inBucket = static_cast<UtlLink*>(inBucket->UtlChain::next)
        )
   {
   }
   link->UtlChain::listBefore(bucket, inBucket);

   resizeIfNeededAndSafe();
}