aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md62
1 files changed, 31 insertions, 31 deletions
diff --git a/README.md b/README.md
index 7e36cd3..7bcc851 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@ Immutable [![release](https://img.shields.io/github/release/benbjohnson/immutabl
=========
This repository contains *generic* immutable collection types for Go. It includes
-`List`, `Map`, `SortedMap`, `Set` and `SortedSet` implementations. Immutable collections can
+`Vector`, `Map`, `SortedMap`, `Set` and `SortedSet` implementations. Immutable collections can
provide efficient, lock free sharing of data by requiring that edits to the
collections return new collections.
@@ -16,25 +16,25 @@ additional CPU and memory overhead. Please evaluate the cost/benefit for your
particular project.
Special thanks to the [Immutable.js](https://immutable-js.github.io/immutable-js/)
-team as the `List` & `Map` implementations are loose ports from that project.
+team as the `Vector` & `Map` implementations are loose ports from that project.
-## List
+## Vector
-The `List` type represents a sorted, indexed collection of values and operates
+The `Vector` type represents a sorted, indexed collection of values and operates
similarly to a Go slice. It supports efficient append, prepend, update, and
slice operations.
-### Adding list elements
+### Adding vector elements
-Elements can be added to the end of the list with the `Append()` method or added
-to the beginning of the list with the `Prepend()` method. Unlike Go slices,
+Elements can be added to the end of the vector with the `Append()` method or added
+to the beginning of the vector with the `Prepend()` method. Unlike Go slices,
prepending is as efficient as appending.
```go
-// Create a list with 3 elements.
-l := immutable.NewList[string]()
+// Create a vector with 3 elements.
+l := immutable.NewVector[string]()
l = l.Append("foo")
l = l.Append("bar")
l = l.Prepend("baz")
@@ -45,30 +45,30 @@ fmt.Println(l.Get(1)) // "foo"
fmt.Println(l.Get(2)) // "bar"
```
-Note that each change to the list results in a new list being created. These
-lists are all snapshots at that point in time and cannot be changed so they
+Note that each change to the vector results in a new vector being created. These
+vectors are all snapshots at that point in time and cannot be changed so they
are safe to share between multiple goroutines.
-### Updating list elements
+### Updating vector elements
You can also overwrite existing elements by using the `Set()` method. In the
-following example, we'll update the third element in our list and return the
-new list to a new variable. You can see that our old `l` variable retains a
+following example, we'll update the third element in our vector and return the
+new vector to a new variable. You can see that our old `l` variable retains a
snapshot of the original value.
```go
-l := immutable.NewList[string]()
+l := immutable.NewVector[string]()
l = l.Append("foo")
l = l.Append("bar")
-newList := l.Set(2, "baz")
+newVector := l.Set(2, "baz")
fmt.Println(l.Get(1)) // "bar"
-fmt.Println(newList.Get(1)) // "baz"
+fmt.Println(newVector.Get(1)) // "baz"
```
-### Deriving sublists
+### Deriving subvectors
-You can create a sublist by using the `Slice()` method. This method works with
+You can create a subvector by using the `Slice()` method. This method works with
the same rules as subslicing a Go slice:
```go
@@ -79,18 +79,18 @@ fmt.Println(l.Get(0)) // "baz"
fmt.Println(l.Get(1)) // "foo"
```
-Please note that since `List` follows the same rules as slices, it will panic if
+Please note that since `Vector` follows the same rules as slices, it will panic if
you try to `Get()`, `Set()`, or `Slice()` with indexes that are outside of
-the range of the `List`.
+the range of the `Vector`.
-### Iterating lists
+### Iterating vectors
-Iterators provide a clean, simple way to iterate over the elements of the list
+Iterators provide a clean, simple way to iterate over the elements of the vector
in order. This is more efficient than simply calling `Get()` for each index.
-Below is an example of iterating over all elements of our list from above:
+Below is an example of iterating over all elements of our vector from above:
```go
itr := l.Iterator()
@@ -107,25 +107,25 @@ By default iterators start from index zero, however, the `Seek()` method can be
used to jump to a given index.
-### Efficiently building lists
+### Efficiently building vectors
-If you are building large lists, it is significantly more efficient to use the
-`ListBuilder`. It uses nearly the same API as `List` except that it updates
-a list in-place until you are ready to use it. This can improve bulk list
+If you are building large vectors, it is significantly more efficient to use the
+`VectorBuilder`. It uses nearly the same API as `Vector` except that it updates
+a vector in-place until you are ready to use it. This can improve bulk vector
building by 10x or more.
```go
-b := immutable.NewListBuilder[string]()
+b := immutable.NewVectorBuilder[string]()
b.Append("foo")
b.Append("bar")
b.Set(2, "baz")
-l := b.List()
+l := b.Vector()
fmt.Println(l.Get(0)) // "foo"
fmt.Println(l.Get(1)) // "baz"
```
-Builders are invalid after the call to `List()`.
+Builders are invalid after the call to `Vector()`.
## Map