Skip to content

Commit

Permalink
doc: update readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
ghosind committed Aug 15, 2023
1 parent 69ea4f7 commit 4cb8817
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ Generics collections framework for Golang.

This package provides the following data structure interfaces and implementations:

- `Collection`: The root interface of most of the structures in this package.
- `Collection`: The root interface of most of the structures in this package (without `Dictionary`).

- `Set`: A collection interface that contains no duplicate elements.

- [`HashSet`](https://pkg.go.dev/github.com/ghosind/collection#HashSet): The implementation of Set based on Go built-in map structure.
- [`HashSet`](https://pkg.go.dev/github.com/ghosind/collection/set#HashSet): The implementation of Set based on Go built-in map structure.

- [`ConcurrentHashSet`](https://pkg.go.dev/github.com/ghosind/collection#ConcurrentHashSet): The thread safe implementation of Set based on Go built-in map structure.
- [`ConcurrentHashSet`](https://pkg.go.dev/github.com/ghosind/collection/set#ConcurrentHashSet): The thread safe implementation of Set based on Go built-in map structure.

- `Map`: A object that maps keys to values, and it cannot contain duplicate key.
- `Dictionary`: A object that maps keys to values, and it cannot contain duplicate key.

- [`HashMap`](https://pkg.go.dev/github.com/ghosind/collection#HashMap): The implementation of Map based on Go built-in map structure.
- [`HashDictionary`](https://pkg.go.dev/github.com/ghosind/collection/dict#ConcurrentHashDictionary): The implementation of Dictionary based on Go built-in map structure.

- [`ConcurrencyHashDictionary`](https://pkg.go.dev/github.com/ghosind/collection/dict#ConcurrencyHashDictionary): The thread safe implementation of HashDictionary.

## Installation

Expand All @@ -47,11 +49,26 @@ import "github.com/ghosind/collection"
Create a string set, add and test elements in the set.

```go
fruits := collection.NewHashSet[string]()
// import "github.com/ghosind/collection/set"

fruits := set.NewHashSet[string]()

fruits.Add("Apple")
fruits.Add("Banana")

log.Print(fruits.Contains("Banana")) // true
log.Print(fruits.Contains("Lemon"))
```

### HashDictionary Examples

```go
// import "github.com/ghosind/collection/dict"

languages := dict.NewHashDictionary[string, int]()

languages.Put("C", 1972)
languages.Put("Go", 2007)

log.Print(languages.GetDefault("C", 0)) // 1972
```

0 comments on commit 4cb8817

Please sign in to comment.