Skip to content

Commit 63bd6ff

Browse files
author
Marouane Ougnou
committed
Pushing
1 parent e43164f commit 63bd6ff

File tree

3 files changed

+82
-18
lines changed

3 files changed

+82
-18
lines changed

iterator.hpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,45 +106,54 @@ namespace ft
106106
it._ptr++;
107107
return (it);
108108
}
109-
difference_type operator-(const myiterator &first)
109+
template <typename S>
110+
difference_type operator-(const myiterator<S> &first)
110111
{
111112
return (this->_ptr - first._ptr);
112113
}
113114
reference operator[](const int &a)
114115
{
115116
return _ptr[a];
116117
}
117-
bool operator==(const myiterator& a)
118-
{
119-
if (this->_ptr == a._ptr)
120-
return (true);
121-
return (false);
118+
template <typename S>
119+
bool operator==(const myiterator<S> &it) const
120+
{
121+
return (this->_ptr == it.base());
122122
}
123-
bool operator!=(const myiterator& a)
123+
124+
template <typename S>
125+
bool operator!=(const myiterator<S>& a)
124126
{
125127
if (this->_ptr != a._ptr)
126128
return (true);
127129
return (false);
128130
}
129-
bool operator>(const myiterator& a)
131+
template <typename S>
132+
bool operator>(const myiterator<S>& a)
130133
{
131134
if (this->_ptr > a._ptr)
132135
return (true);
133136
return (false);
134137
}
135-
bool operator<(const myiterator& a)
138+
139+
template <typename S>
140+
bool operator<(const myiterator<S>& a)
136141
{
137142
if (this->_ptr < a._ptr)
138143
return (true);
139144
return (false);
140145
}
141-
bool operator<=(const myiterator& a)
146+
147+
template <typename S>
148+
bool operator<=(const myiterator<S>& a)
142149
{
143150
if (this->_ptr <= a._ptr)
144151
return (true);
145152
return (false);
146153
}
147-
bool operator>=(const myiterator& a)
154+
155+
template <typename S>
156+
bool operator>=(const myiterator<S>& a)
148157
{
149158
if (this->_ptr >= a._ptr)
150159
return (true);

main.cpp

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,53 @@ int main()
131131
std::cout << "stack size ==> " << iterable_stack.size() << std::endl;
132132
std::cout << std::endl;
133133
return (0);
134-
}
134+
}
135+
136+
//*Iterator Operators
137+
//https://docs.microsostd.com/en-us/cpp/standard-library/iterator-operators?view=msvc-170
138+
139+
//*ptrdiff_t
140+
//https://stackoverflow.com/questions/4377308/c-size-t-or-ptrdiff-t
141+
142+
//*Red Black Tree
143+
//http://staff.ustc.edu.cn/~csli/graduate/algorithms/book6/chap14.htm
144+
145+
//*AVL trees
146+
//https://www.youtube.com/watch?v=-9sHvAnLN_w
147+
148+
//*Const Correctness
149+
//https://isocpp.org/wiki/faq/const-correctness#overview-const
150+
151+
//*Istream iterator
152+
//https://www.cplusplus.com/reference/iterator/istream_iterator/
153+
154+
//*Destroy vs Deallocate
155+
//https://stackoverflow.com/questions/26667026/difference-between-destroy-destructor-deallocate-in-stdallocator
156+
157+
//*Introduction to trees
158+
//https://www.programiz.com/dsa/trees
159+
//https://www.softwaretestinghelp.com/trees-in-cpp/
160+
161+
//*Avl
162+
//https://www.guru99.com/avl-tree.html (very good to understand rotations)
163+
//https://simplesnippets.tech/what-is-avl-tree-data-structure-all-avl-operations-with-full-code/ (Very Good)
164+
//https://algorithmtutor.com/Data-Structures/Tree/AVL-Trees/
165+
//https://www.techiedelight.com/inorder-tree-traversal-iterative-recursive/
166+
//https://www.softwaretestinghelp.com/avl-trees-and-heap-data-structure-in-cpp/
167+
//https://www.geeksforgeeks.org/avl-trees-containing-a-parent-node-pointer/
168+
169+
//*Avl (Vids)
170+
//https://www.youtube.com/watch?v=vRwi_UcZGjU
171+
//https://www.youtube.com/watch?v=otiDcwZbCo4
172+
//https://www.youtube.com/watch?v=u3OVSkuOdqI (Very Good)
173+
//https://www.youtube.com/watch?v=otiDcwZbCo4
174+
175+
//*Avl Visualizer
176+
//https://www.cs.usfca.edu/~galles/visualization/AVLtree.html
177+
178+
//* Avl Traversal
179+
//https://www.cs.odu.edu/~zeil/cs361/latest/Public/treetraversal/index.html
180+
//https://www.techiedelight.com/inorder-tree-traversal-iterative-recursive/
181+
182+
//* Rebind
183+
//https://stackoverflow.com/questions/22384231/is-use-of-allocatorrebind-required-by-c-standard

map_iterator.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,37 +117,43 @@ namespace ft
117117
return (&operator*());
118118
}
119119

120-
bool operator==(const map_iterator& it) const
120+
template <typename S>
121+
bool operator==(const map_iterator<S>& it) const
121122
{
122123
if (ptr == it.ptr)
123124
return (true);
124125
return (false);
125126
}
126-
bool operator!=(const map_iterator& it) const
127+
template <typename S>
128+
bool operator!=(const map_iterator<S>& it) const
127129
{
128130
if (ptr != it.ptr)
129131
return (true);
130132
return (false);
131133
}
132-
bool operator>(const map_iterator& it) const
134+
template <typename S>
135+
bool operator>(const map_iterator<S>& it) const
133136
{
134137
if (ptr > it.ptr)
135138
return (true);
136139
return (false);
137140
}
138-
bool operator<(const map_iterator& it) const
141+
template <typename S>
142+
bool operator<(const map_iterator<S>& it) const
139143
{
140144
if (ptr < it.ptr)
141145
return (true);
142146
return (false);
143147
}
144-
bool operator<=(const map_iterator& it) const
148+
template <typename S>
149+
bool operator<=(const map_iterator<S>& it) const
145150
{
146151
if (ptr <= it.ptr)
147152
return (true);
148153
return (false);
149154
}
150-
bool operator>=(const map_iterator& it) const
155+
template <typename S>
156+
bool operator>=(const map_iterator<S>& it) const
151157
{
152158
if (ptr >= it.ptr)
153159
return (true);

0 commit comments

Comments
 (0)