Posts

Showing posts with the label iterator

Linear Hashig ForwardIterator Implementation begin() & end()

Image
Clash Royale CLAN TAG #URR8PPP Linear Hashig ForwardIterator Implementation begin() & end() I'm implementing an Iterator for a data structure that works based on Linear Hashing Algorithm. As this data structure uses buckets(arrays) and each bucket can further own have its own bucket(also an array) and all of them are structured via table which is dynamically growing. To implement begin() method i simply set the iterator to the very first element in the table. The code is: const_iterator begin() const { if(this->empty()) { return end(); } //if container is empty return end iterator //else return the iterator to first taken element //try only passing to the first element regardless if its full or not cause it shouldnt make a difference bucket* next{table[0]}; element* ptr{next->Bucket}; return const_iterator{ptr, table}; } To implement end() method my idea was to create an additional array at the bottom of the table which will not be used during inse...