collections library

πŸ“š Jetleaf Collections, Linear Topologies & Accumulators Subsystem

This library provides high-performance data structures, specialized collection implementations, and streaming collectors optimized for enterprise backend workloads in Dart.

Key capabilities:

  • Resizing Linear Buffers: Low-allocation ArrayList with capacity pre-allocation.
  • Doubly-Linked Nodes: Deterministic $O(1)$ insertion and removal with LinkedList.
  • LIFO/FIFO Topologies: Strict FIFO Queue / LinkedQueue and LIFO Stack / LinkedStack.
  • Case-Insensitive Indexing: CaseInsensitiveMap for headers, query params, and environment keys.
  • Functional Collectors: Java/Stream-style stream reductions and grouping operations.

πŸ“Š Collection Topology Matrix

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Specialized Collections                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Linear Arrays     β”‚ Node-Linked Lists β”‚ Specialized Maps    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β€’ ArrayList<E>    β”‚ β€’ LinkedList<E>   β”‚ β€’ HashMap<K, V>     β”‚
β”‚ β€’ Stack<E>        β”‚ β€’ LinkedQueue<E>  β”‚ β€’ CaseInsensitiveMapβ”‚
β”‚ β€’ Queue<E>        β”‚ β€’ LinkedStack<E>  β”‚ β€’ HashSet<E>        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“¦ Exports Categorization

πŸ“‹ Lists & Buffers

  • ArrayList β€” indexable array with dynamic capacity expansion and minimal memory churn.
  • LinkedList β€” doubly-linked list supporting fast constant-time head and tail operations.

πŸ“₯ Queues & Stacks

πŸ—ƒοΈ Maps & Sets

  • CaseInsensitiveMap β€” map whose string keys are matched case-insensitively while preserving original case.
  • HashMap, HashSet β€” high-performance hashing structures.

πŸ§ͺ Collectors & Reductions

  • Collector β€” functional reduction contract transforming elements into aggregated results.
  • Collectors β€” standard factory creating common collectors (toList, toSet, joining, groupingBy).

🎯 Usage Example: Case-Insensitive Headers & Collectors

import 'package:jetleaf_core/collections.dart';

void main() {
  // 1. Case-insensitive HTTP header map
  final headers = CaseInsensitiveMap<String>();
  headers['Content-Type'] = 'application/json';
  headers['Authorization'] = 'Bearer token_abc123';

  // Lookups succeed regardless of case
  print(headers['content-type']); // 'application/json'
  print(headers['AUTHORIZATION']); // 'Bearer token_abc123'

  // 2. Linear ArrayList with collectors
  final list = ArrayList<int>.of([10, 20, 30, 40]);
  final sum = list.fold<int>(0, (prev, curr) => prev + curr);
  print('Total sum: $sum');
}

Classes

AdaptableList
A specialized list collection that can adapt itself or another source into a strongly-typed List of elements.
AdaptableMap
A specialized map collection that can adapt itself or another source into a strongly-typed Map of keys and values.
AdaptableSet
A specialized set collection that can adapt itself or another source into a strongly-typed Set of elements.
ArrayList<E>
A resizable array implementation similar to Java's ArrayList.
CaseInsensitiveMap<V>
A map that performs case-insensitive string key lookups while preserving the original casing of keys.
Collector<T, A, R>
A mutable reduction operation that accumulates input elements into a mutable result container, optionally transforming the accumulated result into a final representation after all input elements have been processed.
Collectors
Implementations of Collector that implement various useful reduction operations, such as accumulating elements into collections, summarizing elements according to various criteria, etc.
HashMap<K, V>
A custom implementation of a hash map that implements the Map<K, V> interface.
HashSet<E>
A custom implementation of a hash set that implements the Set<E> interface.
LinkedList<E>
A custom implementation of a doubly linked list that implements the standard List<E> interface.
LinkedQueue<E>
A queue implementation using a linked list structure, mimicking Java's LinkedList as Queue.
LinkedStack<E>
A stack implementation using a linked list structure, mimicking Java's LinkedList as Stack.
Queue<E>
A first-in-first-out (FIFO) queue interface implementation, mimicking Java's Queue.
Stack<E>
A last-in-first-out (LIFO) stack implementation, mimicking Java's Stack.