Sq::Collections
This is an overview of the Collections provided by Sq
.
Sq::Collections::Seq
Automatically loaded when loading Sq
. Available under the package Seq
.
A sequence is a lazy List/Array implementation. It nearly offers the same API as an Array
but it is lazy, that means it only creates as much entries as you request from it. A sequence can be infinite. As it is an iterator it also offers immediat results compared to an Array
that needs to process all it's data at once. It usually always is less memory consuming compared to an Array
. When you don't need to iterate all elements it can be faster compared to an Array
, otherwise slower.
Sq::Collections::Array
Automatically loaded when loading Sq
. Available under the package Array
.
This is not a re-implementation of an Array. It just uses the Perl built-in Array. It adds a blessing to the array-reference so you can call methods on it. You are supposed to work with it like a normal Array.
Sq::Collections::Hash
Automatically loaded when loading Sq
. Available under the package Hash
.
This is not a re-implementation of an hash. It just uses the Perl built-in Hash. It adds a blessing to the hash-reference so you can call methods on it. You are supposed to work with it like a normal Hash.
Sq::Collections::Heap
Automatically loaded when loading Sq
. Available under the package Heap
.
A Heap
is also sometimes called a Priority Queue. A Heap
offers fast insertion and removal of the smallest element.
Sq::Collections::Queue
Automatically loaded when loading Sq
. Available under the package Queue
.
A Queue
offers efficent adding at the end and removal at the beginning. It's a FIFO structure. First in, First Out.
Queue
can be used, but it's internals will likely change because it doesn't offer the performance I expect.
Sq::Collections::List
Automatically loaded when loading Sq
. Available under the package List
.
This List
is an immutable linked-list implementation.
It's not directly immutable. Theoretically it is mutable but the way how this linked list works makes it unpractically to work with mutation. It's so unpractically that you likely use an Array
instead. Because of it's design it can enforce immutability at certain places.
This data-structure has no priority at the moment and lacks behind of the features of Seq
and Array
. Once Seq
and Array
are finished this data-structure will be updated to reflect the latest changes.
Sq::Collections::Set
NOT YET IMPLEMENTED
This will be a data-structure similar to an Array
that only allows values to appear once in it. Also has no priority at the moment. When you need this then you can use a Hash
instead.