Package list implements a dynamic list data structure backed by a B+ tree. It provides O(log n) operations for most list operations while maintaining order stability.
The list supports various operations including append, get, set, delete, range queries, and iteration. It can store values of any type.
Example usage:
Example
1// Create a new list and add elements
2var l list.List
3l.Append(1, 2, 3)
4
5// Get and set elements
6value, _ := l.Get(1) // returns 2
7l.Set(1, 42) // updates index 1 to 42
8
9// Delete elements
10l.Delete(0) // removes first element
11
12// Iterate over elements
13l.ForEach(func(index int, value any) bool {
14 ufmt.Printf("index %d: %v\n", index, value)
15 return false // continue iteration
16})
17// Output:
18// index 0: 42
19// index 1: 3
20
21// Create a list using a variable declaration
22var l2 list.List
23l2.Append(4, 5, 6)
24println(l2.Len()) // Output: 3