81 template <
typename K_TYPE,
86 :
public hashTable<K_TYPE, V_TYPE, ALLOC, HASH>,
87 public map<K_TYPE, V_TYPE, ALLOC>,
88 public iterable<couple<const K_TYPE, V_TYPE>>,
117 class Iterator final :
public hashTable<K_TYPE, V_TYPE, ALLOC, HASH>::Iterator,
128 u_integer bucket = 0, hashNode* node =
nullptr);
138 friend class hashMap;
144 Iterator(
const Iterator& other);
151 Iterator&
operator=(
const Iterator& other);
157 Iterator*
clone()
const override;
163 [[nodiscard]] std::string
className()
const override;
188 [[nodiscard]]
bool hasNext()
const override;
194 [[nodiscard]]
bool hasPrev()
const override;
213 void next()
const override;
219 void prev()
const override;
225 Iterator*
getPrev()
const override;
249 [[nodiscard]]
bool isValid()
const override;
251 ~Iterator()
override =
default;
259 explicit hashMap(HASH
hash = HASH{}, ALLOC alloc = ALLOC{});
307 bool contains(
const couple<const K_TYPE, V_TYPE> &e)
const override;
315 bool add(
const K_TYPE &k,
const V_TYPE &v)
override;
322 bool remove(
const K_TYPE &k)
override;
329 [[nodiscard]]
bool containsKey(
const K_TYPE &k)
const override;
337 V_TYPE
get(
const K_TYPE &k)
const override;
345 bool update(
const K_TYPE &key,
const V_TYPE &value)
override;
353 const V_TYPE &
operator[](
const K_TYPE &k)
const override;
361 V_TYPE &
operator[](
const K_TYPE &k)
override;
367 Iterator*
begins()
const override;
373 Iterator*
ends()
const override;
379 [[nodiscard]] std::string
className()
const override;
386 [[nodiscard]] std::string
toString(
bool enter)
const override;
417 template <
typename K_TYPE,
422 public map<K_TYPE, V_TYPE, ALLOC>,
423 public iterable<couple<const K_TYPE, V_TYPE>>,
436 using RBNode =
typename RBTreeType::RBNode;
452 class Iterator final :
public RBTreeType::Iterator,
460 explicit Iterator(RBTreeType* tree, RBNode* cur);
470 friend class treeMap;
476 Iterator(
const Iterator& other);
483 Iterator&
operator=(
const Iterator& other);
489 Iterator*
clone()
const override;
495 [[nodiscard]] std::string
className()
const override;
518 [[nodiscard]]
bool hasNext()
const override;
524 [[nodiscard]]
bool hasPrev()
const override;
543 void next()
const override;
548 void prev()
const override;
554 Iterator*
getPrev()
const override;
578 [[nodiscard]]
bool isValid()
const override;
580 ~Iterator()
override =
default;
638 bool contains(
const couple<const K_TYPE, V_TYPE> &e)
const override;
646 bool add(
const K_TYPE &k,
const V_TYPE &v)
override;
653 bool remove(
const K_TYPE &k)
override;
660 [[nodiscard]]
bool containsKey(
const K_TYPE &k)
const override;
668 V_TYPE
get(
const K_TYPE &k)
const override;
676 bool update(
const K_TYPE &key,
const V_TYPE &value)
override;
684 const V_TYPE &
operator[](
const K_TYPE &k)
const override;
692 V_TYPE &
operator[](
const K_TYPE &k)
override;
698 Iterator*
begins()
const override;
704 Iterator*
ends()
const override;
710 [[nodiscard]] std::string
className()
const override;
717 [[nodiscard]] std::string
toString(
bool enter)
const override;
751 template <
typename K_TYPE,
755 class JMap final :
public skipList<const K_TYPE, V_TYPE, ALLOC, Compare>,
756 public map<K_TYPE, V_TYPE, ALLOC>,
757 public iterable<couple<const K_TYPE, V_TYPE>>,
766 using skipListNode =
typename skipListType::skipListNode;
782 class Iterator final :
public skipListType::Iterator,
801 explicit Iterator(skipListNode* cur);
826 [[nodiscard]] std::string
className()
const override;
851 [[nodiscard]]
bool hasNext()
const override;
856 [[nodiscard]]
bool hasPrev()
const override;
875 void next()
const override;
880 void prev()
const override;
908 [[nodiscard]]
bool isValid()
const override;
968 bool contains(
const couple<const K_TYPE, V_TYPE> &e)
const override;
976 bool add(
const K_TYPE &k,
const V_TYPE &v)
override;
983 bool remove(
const K_TYPE &k)
override;
990 [[nodiscard]]
bool containsKey(
const K_TYPE &k)
const override;
998 V_TYPE
get(
const K_TYPE &k)
const override;
1006 bool update(
const K_TYPE &key,
const V_TYPE &value)
override;
1014 const V_TYPE &
operator[](
const K_TYPE &k)
const override;
1022 V_TYPE &
operator[](
const K_TYPE &k)
override;
1028 Iterator*
begins()
const override;
1034 Iterator*
ends()
const override;
1040 [[nodiscard]] std::string
className()
const override;
1047 [[nodiscard]] std::string
toString(
bool enter)
const override;
1057template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1058original::hashMap<K_TYPE, V_TYPE, HASH, ALLOC>::Iterator::Iterator(
1059 vector<hashNode *, rebind_alloc_pointer> *buckets, u_integer bucket, hashNode *node)
1060 : hashTable<K_TYPE, V_TYPE, ALLOC, HASH>::Iterator(
1061 const_cast<vector<hashNode*, rebind_alloc_pointer>*>(buckets), bucket, node) {}
1063template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1064bool original::hashMap<K_TYPE, V_TYPE, HASH, ALLOC>::Iterator::equalPtr(
1066 auto other_it =
dynamic_cast<const Iterator*
>(other);
1068 this->p_buckets == other_it->p_buckets &&
1069 this->cur_bucket == other_it->cur_bucket &&
1070 this->p_node == other_it->p_node;
1073template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1074original::hashMap<K_TYPE, V_TYPE, HASH, ALLOC>::Iterator::Iterator(
const Iterator &other) : Iterator() {
1078template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1088template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1091 return new Iterator(*
this);
1094template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1096 return "hashMap::Iterator";
1099template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1104template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1109template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1115template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1120template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1125template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1128 auto other_it =
dynamic_cast<const Iterator*
>(other);
1133 if (!
next->isValid()){
1138 return next->equalPtr(other_it);
1141template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1144 return other->atPrev(*
this);
1147template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1152template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1157template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1163template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1169template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1175template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1180template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1185template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1188 map<K_TYPE, V_TYPE, ALLOC>(std::move(alloc)) {}
1190template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1195template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1198 if (
this == &other) {
1202 this->buckets = this->bucketsCopy(other.buckets);
1203 this->size_ = other.size_;
1204 this->hash_ = other.hash_;
1205 if constexpr(ALLOC::propagate_on_container_copy_assignment::value) {
1207 this->rebind_alloc = other.rebind_alloc;
1212template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1217template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1220 if (
this == &other) {
1224 this->buckets = std::move(other.buckets);
1225 this->size_ = other.size_;
1227 this->hash_ = std::move(other.hash_);
1228 if constexpr(ALLOC::propagate_on_container_move_assignment::value) {
1229 this->
allocator = std::move(other.allocator);
1230 this->rebind_alloc = std::move(other.rebind_alloc);
1235template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1241template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1247template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1249 return this->insert(k, v);
1252template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1254 return this->erase(k);
1257template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1259 return this->find(k);
1262template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1264 auto node = this->find(k);
1267 return node->getValue();
1270template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1272 return this->modify(key, value);
1275template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1277 auto node = this->find(k);
1280 return node->getValue();
1283template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1285 auto node = this->find(k);
1287 this->insert(k, V_TYPE{});
1288 node = this->find(k);
1290 return node->getValue();
1293template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1297 if (this->buckets[0]) {
1298 return new Iterator(p_buckets, 0, this->buckets[0]);
1301 return new Iterator(p_buckets, bucket, p_buckets->get(bucket));
1304template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1309 auto node = this->buckets[bucket];
1310 while (node && node->getPNext()) {
1311 node = node->getPNext();
1313 return new Iterator(p_buckets, bucket, node);
1316template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1321template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1323 std::stringstream ss;
1327 for (
auto it = this->
begin(); it != this->
end(); it.next()){
1341template<
typename K_TYPE,
typename V_TYPE,
typename HASH,
typename ALLOC>
1342original::hashMap<K_TYPE, V_TYPE, HASH, ALLOC>::~hashMap() =
default;
1344template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1345original::treeMap<K_TYPE, V_TYPE, Compare, ALLOC>::Iterator::Iterator(RBTreeType* tree, RBNode* cur)
1346 : RBTreeType::Iterator(tree, cur) {}
1348template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1350original::treeMap<K_TYPE, V_TYPE, Compare, ALLOC>::Iterator::equalPtr(
1351 const iterator<couple<const K_TYPE, V_TYPE>>* other)
const
1353 auto other_it =
dynamic_cast<const Iterator*
>(other);
1355 this->tree_ == other_it->tree_ &&
1356 this->cur_ == other_it->cur_;
1359template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1360original::treeMap<K_TYPE, V_TYPE, Compare, ALLOC>::Iterator::Iterator(
const Iterator& other) : Iterator(nullptr, nullptr)
1365template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1369 if (
this == &other) {
1373 this->
tree_ = other.tree_;
1374 this->
cur_ = other.cur_;
1378template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1382 return new Iterator(*
this);
1385template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1388 return "treeMap::Iterator";
1391template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1394 RBTreeType::Iterator::operator+=(steps);
1397template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1400 RBTreeType::Iterator::operator-=(steps);
1403template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1411template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1414 return RBTreeType::Iterator::hasNext();
1417template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1420 return RBTreeType::Iterator::hasPrev();
1423template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1427 auto other_it =
dynamic_cast<const Iterator*
>(other);
1432 if (!
next->isValid()){
1437 return next->equalPtr(other_it);
1440template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1444 return other->atNext(*
this);
1447template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1450 RBTreeType::Iterator::next();
1453template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1456 RBTreeType::Iterator::prev();
1459template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1463 auto it = this->
clone();
1468template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1471 return RBTreeType::Iterator::get();
1474template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1477 return RBTreeType::Iterator::get();
1480template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1486template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1489 return RBTreeType::Iterator::isValid();
1492template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1494 : RBTreeType(std::move(comp)),
1495 map<K_TYPE, V_TYPE, ALLOC>(std::move(alloc)) {}
1497template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1502template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1505 if (
this == &other){
1509 this->destroyTree();
1510 this->root_ = other.treeCopy();
1511 this->size_ = other.size_;
1512 this->compare_ = other.compare_;
1513 if constexpr(ALLOC::propagate_on_container_copy_assignment::value) {
1515 this->rebind_alloc = other.rebind_alloc;
1520template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1525template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1528 if (
this == &other){
1532 this->destroyTree();
1533 this->root_ = other.root_;
1534 other.root_ =
nullptr;
1535 this->size_ = other.size_;
1537 this->compare_ = std::move(other.compare_);
1538 if constexpr(ALLOC::propagate_on_container_move_assignment::value) {
1539 this->
allocator = std::move(other.allocator);
1540 this->rebind_alloc = std::move(other.rebind_alloc);
1545template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1550template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1556template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1558 return this->insert(k, v);
1561template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1563 return this->erase(k);
1566template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1568 return this->find(k);
1571template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1573 auto node = this->find(k);
1576 return node->getValue();
1579template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1581 return this->modify(key, value);
1584template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1586 auto node = this->find(k);
1589 return node->getValue();
1592template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1594 auto node = this->find(k);
1596 this->insert(k, V_TYPE{});
1597 node = this->find(k);
1599 return node->getValue();
1602template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1609template <
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1616template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1621template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1623 std::stringstream ss;
1627 for (
auto it = this->
begin(); it != this->
end(); it.next()){
1641template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1644template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1645bool original::JMap<K_TYPE, V_TYPE, Compare, ALLOC>::Iterator::equalPtr(
1647 auto other_it =
dynamic_cast<const Iterator*
>(other);
1648 return other_it && this->cur_ == other_it->cur_;
1651template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1655template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1659template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1662 skipListType::Iterator::operator=(other);
1665template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1671template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1674 return "JMap::Iterator";
1677template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1679 skipListType::Iterator::operator+=(steps);
1682template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1687template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1691 auto other_it =
dynamic_cast<const Iterator*
>(&other);
1692 if (other_it ==
nullptr)
1693 return this > &other ?
1694 std::numeric_limits<integer>::max() :
1695 std::numeric_limits<integer>::min();
1696 return skipListType::Iterator::operator-(*other_it);
1699template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1701 return skipListType::Iterator::hasNext();
1704template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1709template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1712 const auto other_it =
dynamic_cast<const Iterator*
>(other);
1716 auto cloned_it =
ownerPtr(other_it->clone());
1717 return this->equalPtr(cloned_it.get());
1720template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1723 return other->atPrev(*
this);
1726template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1728 skipListType::Iterator::next();
1731template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1736template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1742template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1744 return skipListType::Iterator::get();
1747template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1749 return skipListType::Iterator::get();
1752template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1757template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1759 return skipListType::Iterator::isValid();
1762template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1764 : skipListType(std::move(comp)) ,
1765 map<K_TYPE, V_TYPE, ALLOC>(std::move(alloc)) {}
1767template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1772template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1775 if (
this == &other){
1779 this->listDestroy();
1780 this->head_ = other.listCopy();
1781 this->size_ = other.size_;
1782 this->compare_ = other.compare_;
1783 if constexpr(ALLOC::propagate_on_container_copy_assignment::value) {
1785 this->rebind_alloc = other.rebind_alloc;
1790template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1795template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1798 if (
this == &other){
1802 this->listDestroy();
1803 this->head_ = other.head_;
1804 other.head_ = other.createNode();
1805 this->size_ = other.size_;
1807 this->compare_ = std::move(other.compare_);
1808 if constexpr(ALLOC::propagate_on_container_move_assignment::value) {
1809 this->
allocator = std::move(other.allocator);
1810 this->rebind_alloc = std::move(other.rebind_alloc);
1815template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1820template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1825template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1827 return this->insert(k, v);
1830template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1832 return this->erase(k);
1835template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1837 return this->find(k);
1840template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1842 auto node = this->find(k);
1845 return node->getValue();
1848template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1850 return this->modify(key, value);
1853template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1855 auto node = this->find(k);
1858 return node->getValue();
1861template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1863 auto node = this->find(k);
1865 this->insert(k, V_TYPE{});
1866 node = this->find(k);
1868 return node->getValue();
1871template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1874 return new Iterator(this->head_->getPNext(1));
1877template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1880 return new Iterator(this->findLastNode());
1883template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1888template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
1890 std::stringstream ss;
1894 for (
auto it = this->
begin(); it != this->
end(); it.next()){
1908template<
typename K_TYPE,
typename V_TYPE,
typename Compare,
typename ALLOC>
Red-Black Tree implementation header.
Memory allocation interface and implementations.
Forward iterator for JMap.
Definition maps.h:783
Iterator & operator=(const Iterator &other)
Copy assignment operator.
Definition maps.h:1661
bool atNext(const iterator< couple< const K_TYPE, V_TYPE > > *other) const override
Checks if other is next to this.
Definition maps.h:1721
Iterator * getPrev() const override
Not supported (throws unSupportedMethodError)
Definition maps.h:1738
bool hasPrev() const override
Not supported (throws unSupportedMethodError)
Definition maps.h:1705
Iterator(skipListNode *cur)
Constructs iterator pointing to specific skip list node.
Definition maps.h:1652
std::string className() const override
Gets iterator class name.
Definition maps.h:1673
integer operator-(const iterator< couple< const K_TYPE, V_TYPE > > &other) const override
Calculates distance between iterators.
Definition maps.h:1689
void prev() const override
Not supported (throws unSupportedMethodError)
Definition maps.h:1732
void operator+=(integer steps) const override
Advances iterator by steps.
Definition maps.h:1678
void operator-=(integer steps) const override
Not supported (throws unSupportedMethodError)
Definition maps.h:1683
void next() const override
Moves to next element.
Definition maps.h:1727
bool isValid() const override
Checks if iterator is valid.
Definition maps.h:1758
void set(const couple< const K_TYPE, V_TYPE > &data) override
Not supported (throws unSupportedMethodError)
Definition maps.h:1753
couple< const K_TYPE, V_TYPE > & get() override
Gets current element (non-const)
Definition maps.h:1743
bool hasNext() const override
Checks if more elements exist in forward direction.
Definition maps.h:1700
bool atPrev(const iterator< couple< const K_TYPE, V_TYPE > > *other) const override
Checks if other is previous to this.
Definition maps.h:1710
Iterator * clone() const override
Creates a copy of this iterator.
Definition maps.h:1667
Skip List based implementation of the map interface.
Definition maps.h:758
bool update(const K_TYPE &key, const V_TYPE &value) override
Updates value for existing key.
Definition maps.h:1849
std::string toString(bool enter) const override
Converts to string representation.
Definition maps.h:1889
Iterator * ends() const override
Gets end iterator.
Definition maps.h:1879
const V_TYPE & operator[](const K_TYPE &k) const override
Const element access.
Definition maps.h:1854
bool remove(const K_TYPE &k) override
Removes key-value pair.
Definition maps.h:1831
bool containsKey(const K_TYPE &k) const override
Checks if key exists.
Definition maps.h:1836
bool contains(const couple< const K_TYPE, V_TYPE > &e) const override
Checks if key-value pair exists.
Definition maps.h:1821
~JMap() override
Destructor.
u_integer size() const override
Gets number of elements.
Definition maps.h:1816
std::string className() const override
Gets class name.
Definition maps.h:1884
bool add(const K_TYPE &k, const V_TYPE &v) override
Adds new key-value pair.
Definition maps.h:1826
Iterator * begins() const override
Gets begin iterator.
Definition maps.h:1873
V_TYPE get(const K_TYPE &k) const override
Gets value for key.
Definition maps.h:1841
JMap & operator=(const JMap &other)
Copy assignment operator.
Definition maps.h:1774
JMap(Compare comp=Compare{}, ALLOC alloc=ALLOC{})
Constructs empty JMap.
Definition maps.h:1763
RBNode * cur_
Definition RBTree.h:222
RBTree * tree_
Definition RBTree.h:221
Red-Black Tree container implementation.
Definition RBTree.h:40
Default memory allocator using allocators utilities.
Definition allocator.h:154
A base class for basic iterators.
Definition iterator.h:296
Container for two heterogeneous elements.
Definition couple.h:37
F_TYPE & first()
Access first element.
Definition couple.h:323
S_TYPE & second()
Access second element.
Definition couple.h:329
Forward declaration of hash class template.
Definition hash.h:80
Bidirectional iterator for hashMap.
Definition maps.h:118
void next() const override
Moves to next element.
Definition maps.h:1148
bool atNext(const iterator< couple< const K_TYPE, V_TYPE > > *other) const override
Checks if other is next to this.
Definition maps.h:1142
Iterator * getPrev() const override
Not supported.
Definition maps.h:1159
Iterator & operator=(const Iterator &other)
Copy assignment operator.
Definition maps.h:1080
bool hasNext() const override
Checks if more elements exist.
Definition maps.h:1116
bool atPrev(const iterator< couple< const K_TYPE, V_TYPE > > *other) const override
Checks if other is previous to this.
Definition maps.h:1126
std::string className() const override
Gets iterator class name.
Definition maps.h:1095
void prev() const override
Not supported.
Definition maps.h:1153
void operator+=(integer steps) const override
Advances iterator by steps.
Definition maps.h:1100
void operator-=(integer steps) const override
Not supported.
Definition maps.h:1105
bool isValid() const override
Checks if iterator is valid.
Definition maps.h:1181
integer operator-(const iterator< couple< const K_TYPE, V_TYPE > > &other) const override
Not supported.
Definition maps.h:1110
void set(const couple< const K_TYPE, V_TYPE > &data) override
Not supported.
Definition maps.h:1176
Iterator * clone() const override
Creates a copy of this iterator.
Definition maps.h:1090
couple< const K_TYPE, V_TYPE > & get() override
Gets current element (non-const)
Definition maps.h:1165
bool hasPrev() const override
Not supported.
Definition maps.h:1121
Hash table based implementation of the map interface.
Definition maps.h:89
hashMap(HASH hash=HASH{}, ALLOC alloc=ALLOC{})
Constructs empty hashMap.
Definition maps.h:1186
u_integer size() const override
Gets number of elements.
Definition maps.h:1237
bool add(const K_TYPE &k, const V_TYPE &v) override
Adds new key-value pair.
Definition maps.h:1248
bool remove(const K_TYPE &k) override
Removes key-value pair.
Definition maps.h:1253
Iterator * ends() const override
Gets end iterator.
Definition maps.h:1306
bool contains(const couple< const K_TYPE, V_TYPE > &e) const override
Checks if key-value pair exists.
Definition maps.h:1243
bool containsKey(const K_TYPE &k) const override
Checks if key exists.
Definition maps.h:1258
std::string className() const override
Gets class name.
Definition maps.h:1317
const V_TYPE & operator[](const K_TYPE &k) const override
Const element access.
Definition maps.h:1276
bool update(const K_TYPE &key, const V_TYPE &value) override
Updates value for existing key.
Definition maps.h:1271
Iterator * begins() const override
Gets begin iterator.
Definition maps.h:1295
std::string toString(bool enter) const override
Converts to string representation.
Definition maps.h:1322
hashMap & operator=(const hashMap &other)
Copy assignment operator.
Definition maps.h:1197
V_TYPE get(const K_TYPE &k) const override
Gets value for key.
Definition maps.h:1263
void next() const
Advances to the next element.
Definition hashTable.h:634
couple< const K_TYPE, V_TYPE > & get()
Gets current key-value pair (non-const)
Definition hashTable.h:668
Iterator & operator=(const Iterator &other)
Copy assignment operator.
Definition hashTable.h:615
static u_integer findPrevValidBucket(vector< hashNode *, rebind_alloc_pointer > *buckets, u_integer bucket)
Finds the previous non-empty bucket.
Definition hashTable.h:590
void operator+=(integer steps) const
Advances iterator by steps positions.
Definition hashTable.h:656
bool isValid() const
Checks if iterator points to valid element.
Definition hashTable.h:687
bool hasNext() const
Checks if more elements are available.
Definition hashTable.h:625
static u_integer findNextValidBucket(vector< hashNode *, rebind_alloc_pointer > *buckets, u_integer bucket)
Finds the next non-empty bucket.
Definition hashTable.h:579
Internal node type for hash table storage.
Definition hashTable.h:71
Hash table implementation with separate chaining.
Definition hashTable.h:55
typename ALLOC::template rebind_alloc< hashNode * > rebind_alloc_pointer
Rebound allocator type for pointer storage.
Definition hashTable.h:174
Comparator for increasing comparison (less than).
Definition comparator.h:63
A base class for iterable containers that support multiple iteration patterns.
Definition iterable.h:59
iterAdaptor first()
Definition iterable.h:561
iterAdaptor end()
Definition iterable.h:542
iterAdaptor begin()
Definition iterable.h:537
Base iterator interface that supports common operations for iteration.
Definition iterator.h:37
Abstract base class for key-value mapping containers.
Definition map.h:49
Exception for missing element requests.
Definition error.h:136
Unique ownership smart pointer with move semantics.
Definition ownerPtr.h:30
Base class providing polymorphic string conversion capabilities.
Definition printable.h:29
static std::string formatString(const TYPE &t)
Universal value-to-string conversion.
Skip List container implementation.
Definition skipList.h:45
Bidirectional iterator for treeMap.
Definition maps.h:453
couple< const K_TYPE, V_TYPE > & get() override
Gets current element (non-const)
Definition maps.h:1469
integer operator-(const iterator< couple< const K_TYPE, V_TYPE > > &other) const override
Not supported (throws unSupportedMethodError)
Definition maps.h:1405
bool hasNext() const override
Checks if more elements exist in forward direction.
Definition maps.h:1412
void next() const override
Moves to next element.
Definition maps.h:1448
bool atNext(const iterator< couple< const K_TYPE, V_TYPE > > *other) const override
Checks if other is next to this.
Definition maps.h:1441
bool atPrev(const iterator< couple< const K_TYPE, V_TYPE > > *other) const override
Checks if other is previous to this.
Definition maps.h:1424
void operator-=(integer steps) const override
Rewinds iterator by steps.
Definition maps.h:1398
Iterator * getPrev() const override
Gets previous iterator.
Definition maps.h:1461
std::string className() const override
Gets iterator class name.
Definition maps.h:1386
Iterator * clone() const override
Creates a copy of this iterator.
Definition maps.h:1380
bool isValid() const override
Checks if iterator is valid.
Definition maps.h:1487
void prev() const override
Moves to previous element.
Definition maps.h:1454
Iterator & operator=(const Iterator &other)
Copy assignment operator.
Definition maps.h:1367
void operator+=(integer steps) const override
Advances iterator by steps.
Definition maps.h:1392
bool hasPrev() const override
Checks if more elements exist in backward direction.
Definition maps.h:1418
void set(const couple< const K_TYPE, V_TYPE > &data) override
Not supported.
Definition maps.h:1481
Red-Black Tree based implementation of the map interface.
Definition maps.h:424
Iterator * begins() const override
Gets begin iterator.
Definition maps.h:1604
treeMap & operator=(const treeMap &other)
Copy assignment operator.
Definition maps.h:1504
std::string className() const override
Gets class name.
Definition maps.h:1617
Iterator * ends() const override
Gets end iterator.
Definition maps.h:1611
bool containsKey(const K_TYPE &k) const override
Checks if key exists.
Definition maps.h:1567
V_TYPE get(const K_TYPE &k) const override
Gets value for key.
Definition maps.h:1572
~treeMap() override
Destructor.
std::string toString(bool enter) const override
Converts to string representation.
Definition maps.h:1622
bool contains(const couple< const K_TYPE, V_TYPE > &e) const override
Checks if key-value pair exists.
Definition maps.h:1552
bool remove(const K_TYPE &k) override
Removes key-value pair.
Definition maps.h:1562
bool add(const K_TYPE &k, const V_TYPE &v) override
Adds new key-value pair.
Definition maps.h:1557
const V_TYPE & operator[](const K_TYPE &k) const override
Const element access.
Definition maps.h:1585
bool update(const K_TYPE &key, const V_TYPE &value) override
Updates value for existing key.
Definition maps.h:1580
treeMap(Compare comp=Compare{}, ALLOC alloc=ALLOC{})
Constructs empty treeMap.
Definition maps.h:1493
u_integer size() const override
Gets number of elements.
Definition maps.h:1546
Exception for unimplemented method calls.
Definition error.h:123
Dynamic array container with amortized constant time operations.
Definition vector.h:43
Comparator base class and concrete comparator classes.
Combines Comparable and CallbackOf for comparison callbacks.
Definition types.h:92
Generic pair container implementation.
Provides a generic hashing utility and a base interface for hashable types.
Implementation of hashTable container.
Abstract base class for map-like container implementations.
Main namespace for the project Original.
Definition algorithms.h:21
std::uint32_t u_integer
32-bit unsigned integer type for sizes and indexes
Definition config.h:43
std::int64_t integer
64-bit signed integer type for arithmetic operations
Definition config.h:35
Exclusive-ownership smart pointer implementation.
Skip List container implementation.