Hierarchical Collections
-
Represents a hierarchical collection of data.
Many efficient data structures naturally contain some hierarchy. Examples include B-trees, adjacency lists in graphs, and elements within a hash table (if using bucket chaining). By explicitly encoding the hierarchical nature of a collection into the the static type, more efficient algorithms are possible to express.
For additional details, please see:
- “Segmented Iterators and Hierarchical Algorithms”, Matthew H. Austern, 2000.
- “Hierarchical Data Structures and Related Concepts for the C++ Standard Library”, Reiter & Rivera, 2013.
Note: due to limitations in Swift’s type system, a single type cannot be both a
HierarchicalCollection
and aCollection
.When conforming to
See moreHierarchicalCollection
, onlyforEachWhile
andcount
are required.Declaration
Swift
public protocol HierarchicalCollection
-
MutableHierarchicalCollection extends
HierarchicalCollection
s to allow mutation of contents.While many algorithms simply query the data structure in order to do their work, some algorithms modify the data structure. This protocol abstracts over a set of common mutation operations of hierarchical data structures.
See moreDeclaration
Swift
public protocol MutableHierarchicalCollection : HierarchicalCollection
-
A dynamically-sized double-ended queue that allows pushing and popping at both the front and the back.
See moreDeclaration
-
A fixed-size, contiguous collection allowing additions and removals at either end (space permitting).
Beware: unbalanced pushes/pops to either the front or the back will result in the effective working size to be diminished. If you would like this to be managed for you automatically, please use a
Deque
.See also
Deque
Declaration
Swift
public struct DoubleEndedBuffer<T>
extension DoubleEndedBuffer: Collection
-
Declaration
Swift
public enum DoubleEndedAllocationPolicy
-
A hierarchical collection composed of
See moreT
hierarchical collections.Declaration
Swift
public struct HierarchicalArray<T> : HierarchicalCollection where T : HierarchicalCollection
-
LeafArray wraps an
Array
to form aHierarchicalCollection
.LeafArray is a “bottom” type within a HierarchicalCollection.
See moreDeclaration
Swift
public struct LeafArray<Element> : HierarchicalCollection