Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ismail Gjevori committed Apr 2, 2022
1 parent c8eb8d3 commit 8f77e88
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ go get github.com/isgj/collection

## Usage

`collection.Vec[T]` implemented as a native go slice `[]T`. Because of this, other than the few currently
[collection.Vec[T]](https://pkg.go.dev/github.com/isgj/collection#Vec) implemented as a native go slice `[]T`. Because of this, other than the few currently
implemented methods you can use `Vec` also as a regular slice.

```go
Expand Down Expand Up @@ -41,7 +41,7 @@ elements of the slice. Check below.

---

`collection.Iterator[T]` is a lazy iterator over a list of values of type `T`.
[collection.Iterator[T]](https://pkg.go.dev/github.com/isgj/collection#Iterator) is a lazy iterator over a list of values of type `T`.

```go
package main
Expand Down Expand Up @@ -86,9 +86,8 @@ func main() {
---

`collection.Map` ...
[collection.Map](https://pkg.go.dev/github.com/isgj/collection#Map)

### TODO
- [ ] Add documentation
- [ ] Add tests
- [ ] Add more structures
[collection.Set](https://pkg.go.dev/github.com/isgj/collection#Set)

[collection.DLList](https://pkg.go.dev/github.com/isgj/collection#DLList)
6 changes: 5 additions & 1 deletion doc.go
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
// Generic data structures in GO.
// collection implements generic data structures in GO.
// collection.Vec and collection.Map are the same as native `slice` and `map` but with some methods.
// collection.Set is a set of comparable values. It is implemented as a map where the values are an empty struct.
// collection.DLList is a doubly linked list which can be used as a stack or a queue. It has fast O(1) operations in both ends.
// collection.Iterator is a lazy generic iterator. It is not limited to the structures defined in this package.
package collection
3 changes: 3 additions & 0 deletions iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ package collection
// When the second returned value is `false` means the value is not valid.
// In this case the zero value of the type `T` is returned and it should not be consumed.
// Consecutive calls after the first time `false` is returned, should return the same values.
//
// Iterator is not limited to the structures defined in this package. The source of the iterated values can be anything.
// Ex: think of iterating over the lines of a file without having to load the whole file into memory, or iterating over the cursor of a database.
type Iterator[T any] func() (T, bool)

// Any returns true as soon as a value satisfies the test, false otherwise.
Expand Down

0 comments on commit 8f77e88

Please sign in to comment.