Template Class ArraySequence
Defined in File ArraySequence.h
Class Documentation
-
template<class T>
class ArraySequence a SEQUENCE realized with a vector that doubles when it is full
Public Types
-
using Pos = long
a position is an index, from -1 to n
-
using size_type = std::size_t
-
using difference_type = std::ptrdiff_t
-
using const_reverse_iterator = std::reverse_iterator<const_iterator>
Public Functions
-
ArraySequence(void)
the empty sequence, with no vector
-
template<std::input_iterator I, std::sentinel_for<I> S>
ArraySequence(I first, S last) the sequence of the items of [ first , last ), in their order
-
ArraySequence(const ArraySequence &other)
-
ArraySequence(ArraySequence &&other) noexcept
the items of other, which is left empty
-
ArraySequence &operator=(ArraySequence other) noexcept
-
bool empty(void) const
-
Pos insert(Pos p, const T &v)
puts v at index p, the items from index p moving one place on, which takes O( n - p ) time, O( 1 ) amortized at the end
- Pre:
0 <= p <= n
- Post:
one item more, v at index p, the others where they were before p and one place on from p (an audit)
-
Pos remove(Pos p)
removes the item at index p, the following ones moving one place back; a vector left a quarter full is halved
- Pre:
0 <= p < n
- Post:
one item less, the others where they were before p and one place back after it (an audit)
-
void write(Pos p, const T &v)
- Pre:
0 <= p < n
- Post:
read( p ) is v, the other items unchanged (an audit)
-
bool operator==(const ArraySequence &o) const
the same items in the same order
-
inline const_iterator begin(void) const
-
inline const_iterator end(void) const
-
inline const_iterator cbegin(void) const
-
inline const_iterator cend(void) const
-
inline reverse_iterator rbegin(void)
-
inline reverse_iterator rend(void)
-
inline const_reverse_iterator rbegin(void) const
-
inline const_reverse_iterator rend(void) const
-
using Pos = long