Change node names to list_node
This commit is contained in:
parent
11d64d12a0
commit
a21c7312f5
@ -33,9 +33,9 @@ namespace rexy{
|
|||||||
class list;
|
class list;
|
||||||
|
|
||||||
namespace detail{
|
namespace detail{
|
||||||
struct node_base{
|
struct list_node_base{
|
||||||
node_base* next = nullptr;
|
list_node_base* next = nullptr;
|
||||||
node_base* prev = nullptr;
|
list_node_base* prev = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -43,14 +43,14 @@ namespace rexy{
|
|||||||
template<class T>
|
template<class T>
|
||||||
struct const_list_iterator;
|
struct const_list_iterator;
|
||||||
template<class T>
|
template<class T>
|
||||||
struct node;
|
struct list_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc = rexy::allocator<T>>
|
template<class T, class Alloc = rexy::allocator<T>>
|
||||||
class list : protected detail::hasallocator<typename std::allocator_traits<Alloc>::template rebind_alloc<detail::node<T>>>
|
class list : protected detail::hasallocator<typename std::allocator_traits<Alloc>::template rebind_alloc<detail::list_node<T>>>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
using node_allocator_type = detail::hasallocator<typename std::allocator_traits<Alloc>::template rebind_alloc<detail::node<T>>>;
|
using node_allocator_type = detail::hasallocator<typename std::allocator_traits<Alloc>::template rebind_alloc<detail::list_node<T>>>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using value_type = T;
|
using value_type = T;
|
||||||
@ -67,10 +67,10 @@ namespace rexy{
|
|||||||
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using node = detail::node<T>;
|
using node = detail::list_node<T>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
detail::node_base m_sentinel = {&m_sentinel, &m_sentinel};
|
detail::list_node_base m_sentinel = {&m_sentinel, &m_sentinel};
|
||||||
size_type m_size = 0;
|
size_type m_size = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -202,9 +202,9 @@ namespace rexy{
|
|||||||
static iterator mergesort(iterator first, size_type firstlen, Comp comp);
|
static iterator mergesort(iterator first, size_type firstlen, Comp comp);
|
||||||
static std::pair<iterator,size_type> ms_split(iterator it, size_type len);
|
static std::pair<iterator,size_type> ms_split(iterator it, size_type len);
|
||||||
|
|
||||||
static void insert_node_(detail::node_base* prev, detail::node_base* n);
|
static void insert_node_(detail::list_node_base* prev, detail::list_node_base* n);
|
||||||
static void remove_node_(detail::node_base* rm);
|
static void remove_node_(detail::list_node_base* rm);
|
||||||
static detail::node_base* get_next_then_move_node_(detail::node_base* dest, detail::node_base* n);
|
static detail::list_node_base* get_next_then_move_node_(detail::list_node_base* dest, detail::list_node_base* n);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,28 +30,28 @@ namespace rexy{
|
|||||||
|
|
||||||
namespace detail{
|
namespace detail{
|
||||||
template<class T>
|
template<class T>
|
||||||
struct node : public node_base{
|
struct list_node : public list_node_base{
|
||||||
T data;
|
T data;
|
||||||
|
|
||||||
constexpr node(node_base* next, node_base* prev, const T& d):
|
constexpr list_node(list_node_base* next, list_node_base* prev, const T& d):
|
||||||
node_base{next, prev},
|
list_node_base{next, prev},
|
||||||
data(d){}
|
data(d){}
|
||||||
constexpr node(node_base* next, node_base* prev, T&& d):
|
constexpr list_node(list_node_base* next, list_node_base* prev, T&& d):
|
||||||
node_base{next, prev},
|
list_node_base{next, prev},
|
||||||
data(std::move(d)){}
|
data(std::move(d)){}
|
||||||
template<class... Args>
|
template<class... Args>
|
||||||
constexpr node(node_base* next, node_base* prev, Args&&... args):
|
constexpr list_node(list_node_base* next, list_node_base* prev, Args&&... args):
|
||||||
node_base{next, prev},
|
list_node_base{next, prev},
|
||||||
data(std::forward<Args>(args)...){}
|
data(std::forward<Args>(args)...){}
|
||||||
constexpr node(const node& n):
|
constexpr list_node(const list_node& n):
|
||||||
node_base(n),
|
list_node_base(n),
|
||||||
data(n.data){}
|
data(n.data){}
|
||||||
constexpr node(node&& n):
|
constexpr list_node(list_node&& n):
|
||||||
node_base(std::move(n)),
|
list_node_base(std::move(n)),
|
||||||
data(std::move(n.data)){}
|
data(std::move(n.data)){}
|
||||||
|
|
||||||
constexpr node* next(void)const{return static_cast<node*>(node_base::next);}
|
constexpr list_node* next(void)const{return static_cast<list_node*>(list_node_base::next);}
|
||||||
constexpr node* prev(void)const{return static_cast<node*>(node_base::prev);}
|
constexpr list_node* prev(void)const{return static_cast<list_node*>(list_node_base::prev);}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -63,9 +63,9 @@ namespace rexy{
|
|||||||
using pointer = value_type*;
|
using pointer = value_type*;
|
||||||
using const_pointer = const value_type*;
|
using const_pointer = const value_type*;
|
||||||
|
|
||||||
using node_t = node<T>;
|
using node_t = list_node<T>;
|
||||||
|
|
||||||
node_base* current = nullptr;
|
list_node_base* current = nullptr;
|
||||||
|
|
||||||
constexpr bool operator==(const list_iterator& other)const noexcept{return current == other.current;}
|
constexpr bool operator==(const list_iterator& other)const noexcept{return current == other.current;}
|
||||||
constexpr bool operator!=(const list_iterator& other)const noexcept{return current != other.current;}
|
constexpr bool operator!=(const list_iterator& other)const noexcept{return current != other.current;}
|
||||||
@ -106,8 +106,8 @@ namespace rexy{
|
|||||||
return list_iterator{current->prev};
|
return list_iterator{current->prev};
|
||||||
}
|
}
|
||||||
|
|
||||||
node_base* nod(void){return current;}
|
list_node_base* nod(void){return current;}
|
||||||
node_base* nod(void)const{return current;}
|
list_node_base* nod(void)const{return current;}
|
||||||
};
|
};
|
||||||
template<class T>
|
template<class T>
|
||||||
struct const_list_iterator{
|
struct const_list_iterator{
|
||||||
@ -120,9 +120,9 @@ namespace rexy{
|
|||||||
using pointer = value_type*;
|
using pointer = value_type*;
|
||||||
using const_pointer = const value_type*;
|
using const_pointer = const value_type*;
|
||||||
|
|
||||||
using node_t = node<T>;
|
using node_t = list_node<T>;
|
||||||
|
|
||||||
const node_base* current = nullptr;
|
const list_node_base* current = nullptr;
|
||||||
|
|
||||||
constexpr bool operator==(const const_list_iterator& other)const noexcept{return current == other.current;}
|
constexpr bool operator==(const const_list_iterator& other)const noexcept{return current == other.current;}
|
||||||
constexpr bool operator!=(const const_list_iterator& other)const noexcept{return current != other.current;}
|
constexpr bool operator!=(const const_list_iterator& other)const noexcept{return current != other.current;}
|
||||||
@ -159,11 +159,11 @@ namespace rexy{
|
|||||||
return const_list_iterator{current->prev};
|
return const_list_iterator{current->prev};
|
||||||
}
|
}
|
||||||
|
|
||||||
const node_base* nod(void)const{return current;}
|
const list_node_base* nod(void)const{return current;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
list_iterator<T> unconst(void){
|
list_iterator<T> unconst(void){
|
||||||
return list_iterator<T>{const_cast<node_base*>(current)};
|
return list_iterator<T>{const_cast<list_node_base*>(current)};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -661,19 +661,19 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
void list<T,Alloc>::insert_node_(detail::node_base* prev, detail::node_base* n){
|
void list<T,Alloc>::insert_node_(detail::list_node_base* prev, detail::list_node_base* n){
|
||||||
n->next = prev->next;
|
n->next = prev->next;
|
||||||
n->prev = prev;
|
n->prev = prev;
|
||||||
prev->next->prev = n;
|
prev->next->prev = n;
|
||||||
prev->next = n;
|
prev->next = n;
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
void list<T,Alloc>::remove_node_(detail::node_base* rm){
|
void list<T,Alloc>::remove_node_(detail::list_node_base* rm){
|
||||||
rm->prev->next = rm->next;
|
rm->prev->next = rm->next;
|
||||||
rm->next->prev = rm->prev;
|
rm->next->prev = rm->prev;
|
||||||
}
|
}
|
||||||
template<class T, class Alloc>
|
template<class T, class Alloc>
|
||||||
detail::node_base* list<T,Alloc>::get_next_then_move_node_(detail::node_base* dest, detail::node_base* n){
|
detail::list_node_base* list<T,Alloc>::get_next_then_move_node_(detail::list_node_base* dest, detail::list_node_base* n){
|
||||||
auto* next = n->next;
|
auto* next = n->next;
|
||||||
remove_node_(n);
|
remove_node_(n);
|
||||||
insert_node_(dest, n);
|
insert_node_(dest, n);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user