makefile really improved on header dependencies
This commit is contained in:
@@ -162,29 +162,26 @@ public:
|
||||
allocator_type get_allocator() const;
|
||||
|
||||
private:
|
||||
size_type _size;
|
||||
node<value_type>* _root;
|
||||
node_sentinel<value_type>* _sentinel;
|
||||
Compare _comp;
|
||||
Alloc _allocator;
|
||||
size_type _size;
|
||||
node<value_type>* _root;
|
||||
sentinel<value_type>* _sentinel;
|
||||
Compare _comp;
|
||||
Alloc _allocator;
|
||||
|
||||
// https://stackoverflow.com/questions/14148756/what-does-template-rebind-do
|
||||
typename Alloc::template rebind< node<value_type> >::other _allocator_node; // Peu clair, verifier syntaxe
|
||||
typename Alloc::template rebind< node_sentinel<value_type> >::other _allocator_node_sentinel; // Peu clair, verifier syntaxe // SENTINELL
|
||||
typename Alloc::template rebind< node<value_type> >::other _allocator_node;
|
||||
typename Alloc::template rebind< sentinel<value_type> >::other _allocator_sentinel;
|
||||
|
||||
void _init_sentinel();
|
||||
pair<iterator, bool> _insert(const value_type& value);
|
||||
node<value_type>* _erase(iterator pos);
|
||||
node<value_type>* _subtree_shift(node<value_type>* st_old, node<value_type>* st_new);
|
||||
void _init_sentinel();
|
||||
node<value_type>* _subtree_shift(node<value_type>* st_old, node<value_type>* st_new);
|
||||
|
||||
// BBST
|
||||
void _insert_rebalancing(node<value_type>* n);
|
||||
void _erase_rebalancing(node<value_type>* n);
|
||||
|
||||
short _compute_height(node<value_type>* n);
|
||||
short _balance_factor(node<value_type>* n);
|
||||
node<value_type>* _rotate_left(node<value_type>* n);
|
||||
node<value_type>* _rotate_right(node<value_type>* n);
|
||||
enum {INSERT, ERASE};
|
||||
void _balance(node<value_type>* n, bool action);
|
||||
short _compute_height(node<value_type>* n);
|
||||
short _balance_factor(node<value_type>* n);
|
||||
node<value_type>* _rotate_left(node<value_type>* n);
|
||||
node<value_type>* _rotate_right(node<value_type>* n);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -14,101 +14,87 @@ template <
|
||||
typename T,
|
||||
typename Compare,
|
||||
typename Allocator
|
||||
> class map_iterator
|
||||
{
|
||||
private:
|
||||
typedef map_iterator Self;
|
||||
> class map_iterator {
|
||||
|
||||
public:
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
typedef pair<const Key, T> value_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef value_type* pointer;
|
||||
typedef value_type& reference;
|
||||
private:
|
||||
typedef map_iterator self;
|
||||
|
||||
map_iterator() : _node(), _sentinel() {}
|
||||
map_iterator(node<value_type>* n, node_sentinel<value_type>* sentinel) : _node(n), _sentinel(sentinel) {} // SENTINELL
|
||||
//map_iterator(node<value_type>* n, node<value_type>* sentinel) : _node(n), _sentinel(sentinel) {}
|
||||
public:
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
typedef pair<const Key, T> value_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef value_type* pointer;
|
||||
typedef value_type& reference;
|
||||
|
||||
reference operator*() const
|
||||
{ return _node->value; }
|
||||
pointer operator->() const
|
||||
{ return &_node->value; }
|
||||
map_iterator() : _node(), _sentinel() {}
|
||||
map_iterator(node<value_type>* n, sentinel<value_type>* sentinel)
|
||||
: _node(n), _sentinel(sentinel) {}
|
||||
|
||||
Self& operator++()
|
||||
reference operator*() const {
|
||||
return _node->value; }
|
||||
pointer operator->() const {
|
||||
return &_node->value; }
|
||||
|
||||
self& operator++() {
|
||||
if (_node == NULL)
|
||||
_node = _sentinel->child->min();
|
||||
else if (_node->right)
|
||||
_node = _node->right->min();
|
||||
else
|
||||
{
|
||||
if (_node == NULL)
|
||||
_node = _sentinel->child->min(); // SENTINELL
|
||||
//_node = _sentinel->min();
|
||||
else if (_node->right)
|
||||
_node = _node->right->min();
|
||||
else
|
||||
node<value_type>* up = _node->up;
|
||||
while (up != NULL && _node == up->right)
|
||||
{
|
||||
node<value_type>* up = _node->up;
|
||||
while (up != NULL && _node == up->right)
|
||||
{
|
||||
_node = up;
|
||||
up = up->up;
|
||||
}
|
||||
_node = up;
|
||||
up = up->up;
|
||||
}
|
||||
return *this;
|
||||
_node = up;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Self& operator--()
|
||||
self& operator--() {
|
||||
if (_node == NULL)
|
||||
_node = _sentinel->child->max();
|
||||
else if (_node->left)
|
||||
_node = _node->left->max();
|
||||
else
|
||||
{
|
||||
if (_node == NULL)
|
||||
_node = _sentinel->child->max(); // SENTINELL
|
||||
//_node = _sentinel->max();
|
||||
else if (_node->left)
|
||||
_node = _node->left->max();
|
||||
else
|
||||
node<value_type>* up = _node->up;
|
||||
while (up != NULL && _node == up->left)
|
||||
{
|
||||
node<value_type>* up = _node->up;
|
||||
while (up != NULL && _node == up->left)
|
||||
{
|
||||
_node = up;
|
||||
up = up->up;
|
||||
}
|
||||
_node = up;
|
||||
up = up->up;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Self operator++(int)
|
||||
{
|
||||
//Self old(*this);
|
||||
Self old = *this;
|
||||
++(*this);
|
||||
return old;
|
||||
_node = up;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
self operator++(int) {
|
||||
self old = *this;
|
||||
++(*this);
|
||||
return old;
|
||||
}
|
||||
|
||||
Self operator--(int)
|
||||
{
|
||||
//Self old(*this);
|
||||
Self old = *this;
|
||||
--(*this);
|
||||
return old;
|
||||
}
|
||||
self operator--(int) {
|
||||
self old = *this;
|
||||
--(*this);
|
||||
return old;
|
||||
}
|
||||
|
||||
node<value_type>* getNode()
|
||||
{ return _node; }
|
||||
const node<value_type>* getNode() const
|
||||
{ return _node; }
|
||||
const node_sentinel<value_type>* getSentinel() const // SENTINELL
|
||||
//const node<value_type>* getSentinel() const
|
||||
{ return _sentinel; }
|
||||
node<value_type>* getNode() { return _node; }
|
||||
const node<value_type>* getNode() const { return _node; }
|
||||
const sentinel<value_type>* getSentinel() const { return _sentinel; }
|
||||
|
||||
// TODO : friend Non-member functions syntaxe pas clair.
|
||||
friend bool operator==(const Self &lhs, const Self &rhs)
|
||||
{ return lhs._node == rhs._node; }
|
||||
friend bool operator!=(const Self &lhs, const Self &rhs)
|
||||
{ return !(lhs._node == rhs._node); }
|
||||
friend bool operator==(const self &lhs, const self &rhs) {
|
||||
return lhs._node == rhs._node; }
|
||||
friend bool operator!=(const self &lhs, const self &rhs) {
|
||||
return !(lhs._node == rhs._node); }
|
||||
|
||||
private:
|
||||
node<value_type>* _node;
|
||||
node_sentinel<value_type>* _sentinel; // SENTINELL
|
||||
//node<value_type>* _sentinel;
|
||||
private:
|
||||
node<value_type>* _node;
|
||||
sentinel<value_type>* _sentinel;
|
||||
};
|
||||
|
||||
template <
|
||||
@@ -116,94 +102,90 @@ template <
|
||||
typename T,
|
||||
typename Compare,
|
||||
typename Allocator
|
||||
> class map_const_iterator
|
||||
{
|
||||
private:
|
||||
typedef map_const_iterator Self;
|
||||
> class map_const_iterator {
|
||||
|
||||
public:
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
typedef pair<const Key, T> value_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef const value_type* pointer;
|
||||
typedef const value_type& reference;
|
||||
private:
|
||||
typedef map_const_iterator self;
|
||||
|
||||
map_const_iterator() : _node(), _sentinel() {}
|
||||
map_const_iterator(const node<value_type>* node, const node_sentinel<value_type>* sentinel) : _node(node), _sentinel(sentinel) {} // SENTINELL
|
||||
//map_const_iterator(const node<value_type>* nodee, const node<value_type>* sentinel) : _node(nodee), _sentinel(sentinel) {}
|
||||
map_const_iterator(const map_iterator<Key, T, Compare, Allocator>& src) : _node(src.getNode()), _sentinel(src.getSentinel()) {}
|
||||
public:
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
typedef pair<const Key, T> value_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef const value_type* pointer;
|
||||
typedef const value_type& reference;
|
||||
|
||||
reference operator*() const
|
||||
{ return _node->value; }
|
||||
pointer operator->() const
|
||||
{ return &_node->value; }
|
||||
map_const_iterator() : _node(), _sentinel() {}
|
||||
map_const_iterator (
|
||||
const node<value_type>* node,
|
||||
const sentinel<value_type>* sentinel)
|
||||
: _node(node), _sentinel(sentinel) {}
|
||||
map_const_iterator (const map_iterator< Key, T, Compare, Allocator >& src)
|
||||
: _node(src.getNode()), _sentinel(src.getSentinel()) {}
|
||||
|
||||
Self& operator++()
|
||||
reference operator*() const {
|
||||
return _node->value; }
|
||||
pointer operator->() const {
|
||||
return &_node->value; }
|
||||
|
||||
self& operator++() {
|
||||
if (_node == NULL)
|
||||
_node = _sentinel->child->min();
|
||||
else if (_node->right)
|
||||
_node = _node->right->min();
|
||||
else
|
||||
{
|
||||
if (_node == NULL)
|
||||
_node = _sentinel->child->min(); // SENTINELL
|
||||
//_node = _sentinel->min();
|
||||
else if (_node->right)
|
||||
_node = _node->right->min();
|
||||
else
|
||||
node<value_type>* up = _node->up;
|
||||
while (up != NULL && _node == up->right)
|
||||
{
|
||||
node<value_type>* up = _node->up;
|
||||
while (up != NULL && _node == up->right)
|
||||
{
|
||||
_node = up;
|
||||
up = up->up;
|
||||
}
|
||||
_node = up;
|
||||
up = up->up;
|
||||
}
|
||||
return *this;
|
||||
_node = up;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Self& operator--()
|
||||
self& operator--() {
|
||||
if (_node == NULL)
|
||||
_node = _sentinel->child->max();
|
||||
else if (_node->left)
|
||||
_node = _node->left->max();
|
||||
else
|
||||
{
|
||||
if (_node == NULL)
|
||||
_node = _sentinel->child->max(); // SENTINELL
|
||||
//_node = _sentinel->max();
|
||||
else if (_node->left)
|
||||
_node = _node->left->max();
|
||||
else
|
||||
node<value_type>* up = _node->up;
|
||||
while (up != NULL && _node == up->left)
|
||||
{
|
||||
node<value_type>* up = _node->up;
|
||||
while (up != NULL && _node == up->left)
|
||||
{
|
||||
_node = up;
|
||||
up = up->up;
|
||||
}
|
||||
_node = up;
|
||||
up = up->up;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Self operator++(int)
|
||||
{
|
||||
Self old = *this;
|
||||
++(*this);
|
||||
return old;
|
||||
_node = up;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
self operator++(int) {
|
||||
self old = *this;
|
||||
++(*this);
|
||||
return old;
|
||||
}
|
||||
|
||||
Self operator--(int)
|
||||
{
|
||||
Self old = *this;
|
||||
--(*this);
|
||||
return old;
|
||||
}
|
||||
self operator--(int) {
|
||||
self old = *this;
|
||||
--(*this);
|
||||
return old;
|
||||
}
|
||||
|
||||
node<value_type>* getNode() const
|
||||
{ return _node; }
|
||||
node<value_type>* getNode() const {
|
||||
return _node; }
|
||||
|
||||
friend bool operator==(const Self &lhs, const Self &rhs)
|
||||
{ return lhs._node == rhs._node; }
|
||||
friend bool operator!=(const Self &lhs, const Self &rhs)
|
||||
{ return !(lhs._node == rhs._node); }
|
||||
friend bool operator==(const self &lhs, const self &rhs) {
|
||||
return lhs._node == rhs._node; }
|
||||
friend bool operator!=(const self &lhs, const self &rhs) {
|
||||
return !(lhs._node == rhs._node); }
|
||||
|
||||
private:
|
||||
const node<value_type>* _node;
|
||||
const node_sentinel<value_type>* _sentinel; // SENTINELL
|
||||
//const node<value_type>* _sentinel;
|
||||
private:
|
||||
const node<value_type>* _node;
|
||||
const sentinel<value_type>* _sentinel;
|
||||
};
|
||||
|
||||
} // namespace ft
|
||||
|
||||
@@ -43,11 +43,11 @@ template < typename ValueType >
|
||||
};
|
||||
|
||||
template < typename ValueType >
|
||||
struct node_sentinel {
|
||||
struct sentinel {
|
||||
|
||||
node<ValueType> *child;
|
||||
|
||||
node_sentinel() : child(NULL) {}
|
||||
sentinel() : child(NULL) {}
|
||||
};
|
||||
|
||||
} // namespace ft
|
||||
|
||||
Reference in New Issue
Block a user