collections

Vec<T> for growable arrays with owned data

Vec&lt;T&gt; is Rust's dynamic array, stored on the heap. It grows as needed, amortizing allocations. I use Vec for collections of owned data, return values, and when you don't know the size upfront. Common methods: .push() appends, .pop() removes the

Laravel collections for data manipulation

Laravel collections provide a fluent, powerful API for working with arrays. Every Eloquent query returns a collection, but I also create collections from arrays with collect(). Methods like map(), filter(), reduce(), groupBy(), and sortBy() transform

HashSet<T> for unique value collections

HashSet&lt;T&gt; stores unique values with O(1) average-case membership tests. It's backed by a HashMap&lt;T, ()&gt;. I use it for deduplication, membership checks, and set operations (.union(), .intersection()). Common methods: .insert(v) adds, .cont

VecDeque<T> for double-ended queue operations

VecDeque&lt;T&gt; is a growable ring buffer supporting efficient push/pop from both ends. I use it for queues, breadth-first search, and sliding windows. Methods: .push_front(), .push_back(), .pop_front(), .pop_back() are all O(1). It's implemented as

HashMap<K, V> for key-value lookups

HashMap&lt;K, V&gt; provides O(1) average-case lookups, inserts, and deletes. Keys must implement Hash + Eq. I use it for caches, indexing, and associative data. Common methods: .insert(k, v) adds/updates, .get(&amp;k) returns Option&lt;&amp;V&gt;, .r

Enumerables and collection manipulation

Ruby's Enumerable module provides rich collection methods. map transforms elements; select/reject filter. reduce aggregates values. find returns first match; find_all returns all matches. group_by partitions by criteria. partition splits into two arra

Java Streams API for data processing

Java Streams provide a functional approach to processing collections with operations like filter, map, and reduce. I use stream() to create streams from collections and apply intermediate operations that are lazy and return new streams. Terminal opera