Esempio n. 1
0
int main(int argc, const char * argv[]) {
    DLL dll = DLL();
    Node *head = dll.getRoot();
    dll.add(&head, 7);
    dll.add(&head, 6);
    dll.add(&head, 5);
    dll.add(&head, 4);
    dll.add(&head, 3);
    dll.add(&head, 2);
    dll.add(&head, 1);
    dll.printList(head);
    return 0;
}
Esempio n. 2
0
void algot::HashTable::resizeTo(unsigned int newSize){
  algot::DLL<std::string>* newTable = new algot::DLL<std::string>[newSize];
  unsigned int newUsedCells = 0;
  for(unsigned int i = 0; i < tableSize; i++){
    algot::DLL<std::string>* list = table + i;
    const algot::DLLNode<std::string>* first = list->getHead()->next_;
    for(auto it = first; it != list->getTail(); it = it->next_){
      std::string newString = std::string(it->value_);
      unsigned int newIndex = useHash(newString, newSize);
      DLL<std::string>* newList = newTable + newIndex;
      if(newList->isEmpty()){
        newUsedCells++;
      }
      newList->add(newString);
    }
  }
  this->usedCells = newUsedCells;
  this->tableSize = newSize;
  delete[] table;
  table = newTable;
}