3 * - By John Hodge (thePowersGang)
17 template <class T,class Alloc> class list_iterator;
18 template <class T> class list_item;
21 template <class T, class Alloc = allocator<T> >
24 typedef ::std::_bits::list_item<T> item_type;
25 typedef ::std::_bits::list_item<const T> const_item_type;
26 friend class ::std::_bits::list_iterator<item_type,Alloc>;
28 typedef typename Alloc::template rebind<item_type>::other item_allocator;
31 typedef Alloc allocator_type;
32 typedef typename allocator_type::reference reference;
33 typedef typename allocator_type::const_reference const_reference;
34 typedef typename allocator_type::pointer pointer;
35 typedef typename allocator_type::const_pointer const_pointer;
36 typedef _bits::list_iterator<T,Alloc> iterator;
37 typedef _bits::list_iterator<const T,Alloc> const_iterator;
38 typedef int difference_type;
39 typedef size_t size_type;
42 item_allocator m_item_allocator;
43 allocator_type m_allocator;
48 list(const allocator_type& alloc = allocator_type()):
54 list(size_t n, const value_type& val = value_type(), const allocator_type& alloc = allocator_type()):
64 list& operator =(const list& x);
67 return iterator(m_start);
69 const_iterator begin() const {
70 return const_iterator(m_start);
76 const_iterator end() const {
77 return const_iterator(0);
84 size_t max_size() const;
87 const T& front() const;
89 const T& back() const;
91 void assign(size_type n, const value_type& val) {
93 for( size_t i = 0; i < n; i ++ )
99 void push_front(const value_type& val) {
100 insert(front(), val);
105 void push_back(const value_type& val) {
112 iterator insert(iterator position, const value_type& val) {
113 item_type *newi = m_item_allocator.allocate(1);
114 m_allocator.construct(&newi->value, val);
115 if( position == end() ) {
121 else if( position == begin() ) {
122 newi->next = m_start;
124 m_start->prev = newi;
128 newi->prev = position.cur->prev;
129 newi->next = position.cur;
130 position.cur->prev->next = newi;
131 position.cur->prev = newi;
135 void insert(iterator position, size_type n, const value_type& val) {
136 for( size_type i = 0; i < n; i ++ )
138 position = insert(position, val);
141 iterator erase(iterator position) {
142 if( position == end() ) {
145 item_type *oldi = position.cur;
149 oldi->prev->next = oldi->next;
151 m_start = oldi->next;
153 oldi->next->prev = oldi->prev;
157 m_allocator.destroy(&oldi->value);
158 m_item_allocator.deallocate(oldi, 1);
165 item_type* item = m_start;
166 m_start = m_start->next;
178 typedef T value_type;
184 template <class T, class Alloc>
185 class list_iterator//:
186 //public bidirectional_iterator_tag;
189 friend class ::std::list<T, Alloc>;
191 bool operator == (const list_iterator& other) const {
192 return cur == other.cur;
194 bool operator != (const list_iterator& other) const {
195 return cur != other.cur;
204 list_iterator& operator ++ () {
207 list_iterator& operator -- () {
212 list_iterator(list_item<T> *item):
218 }; // namespace _bits