Example #1
0
        /* Link pNew element into the hash table pH.  If pEntry!=0 then also
        ** insert pNew into the pEntry hash bucket.
        */
        private static void insertElement(
            Hash pH,      /* The complete hash table */
            _ht pEntry,   /* The entry into which pNew is inserted */
            HashElem pNew /* The element to be inserted */
            )
        {
            HashElem pHead; /* First element already in pEntry */

            if (pEntry != null)
            {
                pHead = pEntry.count != 0 ? pEntry.chain : null;
                pEntry.count++;
                pEntry.chain = pNew;
            }
            else
            {
                pHead = null;
            }

            if (pHead != null)
            {
                pNew.next = pHead;
                pNew.prev = pHead.prev;
                if (pHead.prev != null)
                {
                    pHead.prev.next = pNew;
                }
                else
                {
                    pH.first = pNew;
                }
                pHead.prev = pNew;
            }
            else
            {
                pNew.next = pH.first;
                if (pH.first != null)
                {
                    pH.first.prev = pNew;
                }
                pNew.prev = null;
                pH.first  = pNew;
            }
        }
Example #2
0
 /* Link pNew element into the hash table pH.  If pEntry!=0 then also
 ** insert pNew into the pEntry hash bucket.
 */
 static void insertElement(
     Hash pH,              /* The complete hash table */
     _ht pEntry,           /* The entry into which pNew is inserted */
     HashElem pNew         /* The element to be inserted */
     )
 {
     HashElem pHead;       /* First element already in pEntry */
       if ( pEntry != null )
       {
     pHead = pEntry.count != 0 ? pEntry.chain : null;
     pEntry.count++;
     pEntry.chain = pNew;
       }
       else
       {
     pHead = null;
       }
       if ( pHead != null )
       {
     pNew.next = pHead;
     pNew.prev = pHead.prev;
     if ( pHead.prev != null )
     {
       pHead.prev.next = pNew;
     }
     else
     {
       pH.first = pNew;
     }
     pHead.prev = pNew;
       }
       else
       {
     pNew.next = pH.first;
     if ( pH.first != null )
     {
       pH.first.prev = pNew;
     }
     pNew.prev = null;
     pH.first = pNew;
       }
 }