[−][src]Crate flatk
Flat layout abstraction toolkit.
This library defines low level primitives for organizing flat data arrays into meaningful structures without copying the data.
For example if we have an array of floats representing 3D positions, we may wish to interpret them as triplets:
use flatk::Chunked3; let pos_data = vec![0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0]; let pos = Chunked3::from_flat(pos_data); assert_eq!(pos[0], [0.0; 3]); assert_eq!(pos[1], [1.0; 3]); assert_eq!(pos[2], [0.0, 1.0, 0.0]);
Similarly we may have a non-uniform grouping of array elements, which may for represent a directed graph:
use flatk::Chunked; let neighbours = vec![1, 2, 0, 1, 0, 1, 2]; let neigh = Chunked::from_sizes(vec![1,2,1,3], neighbours); assert_eq!(&neigh[0][..], &[1][..]); assert_eq!(&neigh[1][..], &[2, 0][..]); assert_eq!(&neigh[2][..], &[1][..]); assert_eq!(&neigh[3][..], &[0, 1, 2][..]);
Here neigh
defines the following graph:
0<--->1<--->2
^ ^ ^
\ | /
\ | /
\ | /
\ | /
\|/
3
Re-exports
pub use chunked::*; |
Modules
chunked | |
consts | Type aliases for many constants. |
Structs
ChunkedNIter | |
Chunks | A generic version of the |
Select | A Set that is a non-contiguous, unordered and possibly duplicated selection
of some larger collection. |
Sparse | A |
SparseIter | |
StaticRange | A type of range whose size is determined at compile time.
This represents a range |
Subset | A Set that is a non-contiguous subset of some larger collection.
|
SubsetIter | |
U | Wrapper around |
UniChunked |
|
UniChunkedIter | Generic static sized chunk iterater appropriate for any lightweight view type collection. |
Traits
Array | |
AsSlice | |
AtomIterator | |
AtomMutIterator | |
BoundedRange | A definition of a bounded range. |
ChunkSize | This trait is used to produce the chunk size of a collection if it contains uniformly chunked elements. |
Clear | |
CloneIntoOther | Clone self into a potentially different collection. |
CloneWithStorage | |
Dimension | |
Dummy | A helper trait for constructing placeholder sets for use in |
ExtendFromSlice | |
Get | An index trait for collection types.
Here |
GetIndex | A helper trait analogous to |
IntBound | A helper trait to identify valid types for Range bounds for use as Sets. |
IntoChunkIterator | This trait generalizes the method |
IntoFlat | Convert a collection into its underlying representation, effectively stripping any organizational info. |
IntoOwned | An analog to the |
IntoOwnedData | In contrast to |
IntoParChunkIterator | Parallel version of |
IntoStaticChunkIterator | Iterate over chunks whose size is determined at compile time. Note that each chunk may not be a simple array, although a statically sized chunk of a slice is an array. |
IntoView | |
Isolate | Since we cannot alias mutable references, in order to index a mutable view
of elements, we must consume the original mutable reference. Since we can't
use slices for general composable collections, its impossible to match
against a |
IsolateIndex | A helper trait like |
OwnedSet | |
PermuteInPlace | |
Push | Abstraction for pushing elements of type |
PushArrayTo | |
PushArrayToVec | |
PushChunk | |
ReadSet | |
ReinterpretAsGrouped | |
RemovePrefix | A helper trait used to help implement the Subset. This trait allows abstract collections to remove a number of elements from the beginning, which is what we need for subsets. |
Reserve | A trait that allows the container to allocate additional space without
changing any of the data. The container should allocate space for at least
|
Set | A trait defining a raw buffer of data. This data is typed but not annotated so it can represent anything. For example a buffer of floats can represent a set of vertex colours or vertex positions. |
Sort | |
SplitAt | A helper trait to split a set into two sets at a given index.
This trait is used to implement iteration over |
SplitFirst | Split out the first element of a collection. |
SplitOff | A helper trait to split owned sets into two sets at a given index.
This trait is used to implement iteration over |
SplitPrefix | Split off a number of elements from the beginning of the collection where the number is determined at compile time. |
StaticallySplittable | A marker trait to indicate a collection type that can be chunked. More precisely this is a type that can be composed with types in this crate. |
Storage | Get an immutable reference to the underlying storage type. |
StorageInto | Transform the access pattern of the underlying storage type. This is useful
when the storage is not just a simple |
StorageMut | Get a mutable reference to the underlying storage type. |
StorageView | |
SwapChunks | |
Truncate | Truncate the collection to be a specified length. |
UniChunkable | A trait intended to be implemented on collection types to define the type of
a statically sized chunk in this collection.
This trait is required for composing with |
ValueType | A marker trait to indicate an owned collection type. This is to distinguish them from borrowed slices, which essential to resolve implementation collisions. |
View | A trait defining a collection that can be accessed via an immutable (shared) view. This type of view can be cloned and copied. |
ViewIterator | A convenience trait to allow generic implementations to call an iterator over the view. This
is necessary because the |
ViewMut | A trait defining a collection that can be accessed via a mutable (unique) view. |
ViewMutIterator | |
Viewed | A marker trait to indicate a viewed collection type. Note that collections
can be partially viewed, but only completely viewed collections are marked
by |
WriteSet |
Functions
multiple_mut_refs_compile_test |
Type Definitions
Chunked1 | |
Chunked2 | |
Chunked3 | |
Chunked4 | |
Chunked5 | |
Chunked6 | |
Chunked7 | |
Chunked8 | |
Chunked9 | |
ChunkedN | Define aliases for common uniform chunked types. |
SelectView | A borrowed selection. |
SparseView | A borrowed view of a sparse collection. |
SubsetView | A borrowed subset. |
U1 | |
U2 | |
U3 | |
U4 | |
U5 | |
U6 | |
U7 | |
U8 | |
U9 | |
U10 | |
U11 | |
U12 | |
U13 | |
U14 | |
U15 | |
U16 |