Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjungblut committed Jul 4, 2024
1 parent 96bd87d commit f0f2c40
Showing 1 changed file with 0 additions and 45 deletions.
45 changes: 0 additions & 45 deletions skiplist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,48 +52,3 @@ func main() {
}
}
```

## Using SkipListMap (pre-generics Go <1.18)

Here's an example on how to use it with versions lower than Go 1.18:

```go
skipListMap := skiplist.NewSkipListMap(skiplist.IntComparator)
skipListMap.Insert(13, 91)
skipListMap.Insert(3, 1)
skipListMap.Insert(5, 2)
log.Printf("size: %d", skipListMap.Size())

it, _ := skipListMap.Iterator()
for {
k, v, err := it.Next()
if err == skiplist.Done {
break
}
log.Printf("key: %d, value: %d", k, v)
}

log.Printf("starting at key: %d", 5)
it, _ = skipListMap.IteratorStartingAt(5)
for {
k, v, err := it.Next()
if err == skiplist.Done {
break
}
log.Printf("key: %d, value: %d", k, v)
}

log.Printf("between: %d and %d", 8, 50)
it, _ = skipListMap.IteratorBetween(8, 50)
for {
k, v, err := it.Next()
if err == skiplist.Done {
break
}
log.Printf("key: %d, value: %d", k, v)
}

```

You can supply any kind of element and comparator to sort arbitrary structs and primitives.

0 comments on commit f0f2c40

Please sign in to comment.