rgaufman / live555

A mirror of the live555 source code.
GNU Lesser General Public License v3.0
768 stars 370 forks source link

hashtable rebuild() #9

Closed zhenchengdezhichi closed 8 years ago

zhenchengdezhichi commented 8 years ago

哈希表rebuild的时候为什么指针每一个都去移动一遍,只需要把头指针变更一下就可以了 应该。 for (TableEntry* oldChainPtr = oldBuckets; oldSize > 0; --oldSize, ++oldChainPtr) { for (TableEntry* hPtr = oldChainPtr; hPtr != NULL; hPtr = oldChainPtr) { oldChainPtr = hPtr->fNext;

  unsigned index = hashIndexFromKey(hPtr->key);

  hPtr->fNext = fBuckets[index];//插入在前面的单链表
  fBuckets[index] = hPtr;
}

} 这段是否可以改成 int i = 0 ; for (TableEntry* oldChainPtr = oldBuckets; i < oldSize; ++i, ++oldChainPtr) { fBuckets[i ]=oldChainPtr; }

tetherit commented 8 years ago

English please?