a doubly linked list with one word of links per cell, the exclusive or of the two neighbors
More...
#include <ADS/sequence/XorList.h>
|
| class | Iterator |
| | the bidirectional iterator, the cell and the one before it, on items const if Const More...
|
|
| | XorList (void)=default |
| | the empty list
|
| | XorList (std::initializer_list< T > l) |
| | the items of l, in order
|
| | XorList (const XorList &o) |
| | a copy of o, cell by cell
|
| | XorList (XorList &&o) noexcept |
| | the cells of o, which is left empty
|
| XorList & | operator= (XorList o) noexcept |
| | the items of o, by copy and swap
|
| | ~XorList () |
| | destroys the items
|
| void | swap (XorList &o) noexcept |
| | exchanges the cells with those of o
|
| bool | empty (void) const |
| | true if there is no item
|
| std::size_t | size (void) const |
| | the number \( n \) of items
|
| const T & | front (void) const |
| | the first item
|
| const T & | back (void) const |
| | the last item
|
| void | push_front (const T &x) |
| | \( x \) at the front, \( O( 1 ) \)
|
| void | push_back (const T &x) |
| | \( x \) at the back, \( O( 1 ) \), the mirror of push_front()
|
| void | pop_front (void) |
| | removes the first item, \( O( 1 ) \)
|
| void | pop_back (void) |
| | removes the last item, \( O( 1 ) \), the mirror of pop_front()
|
| void | reverse (void) |
| | the order of the items reversed in \( O( 1 ) \), by exchanging the first and the last cell
|
| void | clear (void) |
| | removes all the items
|
| bool | operator== (const XorList &o) const |
| | the same items in the same order
|
| iterator | begin (void) |
| | the iterator on the first item
|
| iterator | end (void) |
| | the iterator past the last item
|
| const_iterator | begin (void) const |
| | the constant iterator on the first item
|
| const_iterator | end (void) const |
| | the constant iterator past the last item
|
template<class T>
class ADS::XorList< T >
a doubly linked list with one word of links per cell, the exclusive or of the two neighbors
◆ const_iterator
◆ const_reference
◆ difference_type
the type of the distances
◆ iterator
the iterator on the items
◆ reference
◆ size_type
◆ value_type
◆ XorList() [1/4]
◆ XorList() [2/4]
◆ XorList() [3/4]
a copy of o, cell by cell
◆ XorList() [4/4]
the cells of o, which is left empty
◆ ~XorList()
◆ back()
the last item
- Precondition
- the list is not empty
◆ begin() [1/2]
the iterator on the first item
◆ begin() [2/2]
the constant iterator on the first item
◆ clear()
◆ empty()
◆ end() [1/2]
the iterator past the last item
◆ end() [2/2]
the constant iterator past the last item
◆ front()
the first item
- Precondition
- the list is not empty
◆ operator=()
the items of o, by copy and swap
◆ operator==()
the same items in the same order
◆ pop_back()
removes the last item, \( O( 1 ) \), the mirror of pop_front()
- Precondition
- the list is not empty
- Postcondition
- one item less
◆ pop_front()
removes the first item, \( O( 1 ) \)
In pseudocode (Sinha, beyond the book):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{procedure}\ \mathrm{popFront}() \cr
2 & \quad c \gets h;\ h \gets c.\mathit{link}\quad \triangleright
\ \text{its only neighbor} \cr
3 & \quad \textbf{if}\ h \ne \textbf{nil}\ \textbf{then}
\ h.\mathit{link} \gets h.\mathit{link} \oplus c\ \textbf{else}\ t
\gets \textbf{nil} \cr
4 & \quad \text{free } c
\end{array}}
\]
- Precondition
- the list is not empty
- Postcondition
- one item less
◆ push_back()
\( x \) at the back, \( O( 1 ) \), the mirror of push_front()
- Postcondition
- one item more, \( x \) last
◆ push_front()
\( x \) at the front, \( O( 1 ) \)
In pseudocode (Sinha, beyond the book), \( h \) the first cell:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{procedure}\ \mathrm{pushFront}( x ) \cr
2 & \quad c \gets \text{a new cell of } x;\ c.\mathit{link} \gets h \cr
3 & \quad \textbf{if}\ h \ne \textbf{nil}\ \textbf{then}
\ h.\mathit{link} \gets h.\mathit{link} \oplus c\ \textbf{else}\ t
\gets c \cr
4 & \quad h \gets c
\end{array}}
\]
- Postcondition
- one item more, \( x \) first
◆ reverse()
the order of the items reversed in \( O( 1 ) \), by exchanging the first and the last cell
◆ size()
the number \( n \) of items
◆ swap()
exchanges the cells with those of o
The documentation for this class was generated from the following file: