ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
sequence Directory Reference

Files

 
ArraySequence.h
 A SEQUENCE [see ADT.h] realized with a vector: the position of an item is its index, \( \mathit{pos}_i = i \), with \( \mathit{pos}_{-1} = -1 \) and \( \mathit{pos}_n = n \).
 
ContiguousDeque.h
 A double ended queue with no modular arithmetic, beyond the book: the variant of the ArrayDeque of Morin's book asked by its exercise 2.8, the \( n \) items in order in one contiguous piece \( A[ h .. h + n - 1 ] \) of a vector of \( c \) places, so that the item of rank \( i \) is \( A[ h + i ] \), the iterators are pointers and data() gives the items to any function that wants an array.
 
CubishArrayStack.h
 The cubish array stack of exercise 2.12 of Morin's book, beyond the book: a LIST by rank in three levels, whose operator[] takes \( O( 1 ) \) time and whose insertions and removals take \( O( n^{1/3} ) \) amortized time, with \( O( n^{2/3} ) \) places wasted.
 
CursorList.h
 A SEQUENCE [see ADT.h] realized with cursors, beyond the book: the cells of the lists are the places of a vector, a CursorSpace, and a link is the index of the next cell, 0 being nil (the place 0 is never used).
 
DualArrayDeque.h
 The dual array deque of section 2.5 of Morin's book, beyond the book: a LIST by rank made of two stacks back to back, \( F \) with the first items from the top and \( B \) with the others from the bottom, so that the item of rank \( i \) is \( F[ |F| - 1 - i ] \) for \( i < |F| \) and \( B[ i - |F| ] \) otherwise.
 
Fenwick.h
 The prefix aggregates of a sequence by the tree of Fenwick, beyond the book, over any algebra of Algebra.h, and the observer that keeps them for an ObservableArray [see ObservableArray.h].
 
IndexedList.h
 The interfaces of chapter 1 of Morin's book for the sequences, beyond the book, as concepts of C++20 [see ADT.h for those of the book]:
 
List.h
 The LIST of the book: a SEQUENCE [see ADT.h] realized as a bidirectional circular list of cells with a sentinel.
 
ListSort.h
 The sort of a List [see List.h] by relinking its cells, beyond the book, stable, the engineered counterpart of naturalMergeSort() [see SequenceAlgorithms.h], which copies the items through the positions as the book does; no item is copied or moved, and the positions stay on their items.
 
ObservableArray.h
 An array that tells its changes, beyond the book: a vector of values of T whose writes go through the subject policy Policy [see Modification.h], NoObservers by default, with which every operation compiles to the code of the std::vector it holds.
 
OrderMaintenanceList.h
 The order maintenance of exercise 8.11 of Morin (his Sequence), beyond the book: a list of elements with addAfter( e , v ), which adds a new element right after \( e \) (at the front if \( e \) is nil), in \( O( 1 ) \) amortized time, remove( e ), in \( O( 1 ) \) time, and testBefore( a , b ), whether \( a \) comes before \( b \), in \( O( 1 ) \) time.
 
Rearrangements.h
 Rearrangements of a vector in place, by swaps or with a small buffer: the partition into three classes, the alternating order, the sort of a vector whose items are near their places, and the cost of sorting by swaps.
 
RootishArrayStack.h
 The rootish array stack of Brodnik, Carlsson, Demaine, Munro and Sedgewick, beyond the book: a LIST by rank, operator[], insert( i , x ) and erase( i ) (section 2.6 of Morin's book), whose items lie in \( r \) blocks of \( 1 , 2 , \ldots , r \) places, so that a vector that grows never copies its items and wastes only \( O( \sqrt{n} ) \) places, where a vector that doubles [see ArraySequence.h] wastes up to \( 2 n \) of them and copies each item once on average.
 
SEList.h
 The space-efficient list of section 3.3 of Morin's book, beyond the book: a doubly linked list of blocks, each a circular buffer of at most \( b + 1 \) items (an unrolled list), the blocks but the first and the last holding between \( b - 1 \) and \( b + 1 \) items, so that the \( n \) items take \( n + O( b + n / b ) \) places and pointers where a List [see List.h] takes \( 2 n \) pointers more, and a walk reads \( b \) items per block.
 
SequenceAlgorithms.h
 Algorithms on a SEQUENCE [see ADT.h], beyond the book, through its positions only, so that they work on a List and on an ArraySequence:
 
SequenceRange.h
 The range of the items of a SEQUENCE [see ADT.h], beyond the book, so that the for on a range of C++ visits a sequence through its positions: for( const auto & x : range( s ) ) is the loop of the book that sets \( p \) to head(), reads read( p ) and sets \( p \) to next( p ) until finished( p ).
 
SinglyList.h
 A SEQUENCE [see ADT.h] realized as a singly linked list, not circular and with no sentinel (exercise 4.6 of the book).
 
SkipListSequence.h
 The SkiplistList of Morin, beyond the book: a sequence with access, insertion and removal at any index in \( O( \log n ) \) expected time, on a skip list [see SkipList.h] whose links carry their width, the number of items they jump over.
 
SmallVector.h
 A vector with room for \( N \) items inside itself, beyond the book: the vector that doubles of section 4.2 [see ArraySequence.h] whose first \( N \) items need no memory of the allocator, so that the many short vectors of a structure (the children of a node, the arcs of a vertex, the items of a bucket) cost no allocation each and lie next to the object that holds them, at the price of \( N \) items of room in every vector.
 
TieredVector.h
 The tiered vector of Goodrich and Kloss, beyond the book: a sequence with access by index in \( O( 1 ) \) time, as a vector, and insertion and removal at any index in \( O( \sqrt{n} ) \) time, where a vector [see ArraySequence.h] moves \( O( n ) \) items.
 
TreapList.h
 The TreapList of exercise 7.11 of Morin, beyond the book: a sequence with access, insertion and removal at any index in \( O( \log n ) \) expected time, on a treap [see Treap.h] whose symmetric order is the order of the sequence and whose nodes keep the size of their subtree, so that the index of a node is the size of the left subtrees passed on the right along its path (an implicit treap: the keys are the indices, never stored).
 
Treque.h
 The treque (triple ended queue) of exercise 2.3 of Morin's book, beyond the book: a LIST by rank whose operator[] takes \( O( 1 ) \) time and whose insertions and removals at the rank \( i \) take \( O( 1 + \min\{ i , n - i , | n / 2 - i | \} ) \) amortized time, fast near either end and near the middle.
 
XorList.h
 The XOR list of the discussion of chapter 3 of Morin's book, beyond the book: a doubly linked list whose cells keep one word of links instead of two, the exclusive or \( \mathit{prev} \oplus \mathit{next} \) of the addresses of their two neighbors (nil at the ends being 0), so that a walk that knows the cell it comes from finds the next one by an exclusive or, \( \mathit{next} = \mathit{link} \oplus \mathit{prev} \), in either direction.