๐๏ธ Rust Collections
Common
.len()
โ length of sequence[i]
โ item at index i
Types
Arrays
Constant size, single type
[T; N]
- Type: T
- Size: N
Creation
[V; N]
- Creates an array with N items of value V
Vectors
Dynamic size, single type
Vec<T>
- Type: T
- In heap
Functions
.push(x)
โ push x to vector
Creation
vec![...]
- creates new vectors with elements in
[]
- creates new vectors with elements in
vec![V, N]
- creates new vector with N elements of value V
.collect()
Slices
Pointer to first element, with count of accessable elements from it
Other
VecDeque<T>
: like a stack, but accessible from both sidesBinaryHeap<T>
: Loosely organized, greatest value always bubbles up to front of queueHashMap<K, V>, BTreeMap<K,V>
- have
Entry
items
- have