-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,51 @@ | ||
# collection | ||
Generic collections framework for Golang. | ||
|
||
![Test](https://github.com/ghosind/collection/workflows/collection/badge.svg) | ||
[![codecov](https://codecov.io/gh/ghosind/collection/branch/main/graph/badge.svg)](https://codecov.io/gh/ghosind/collection) | ||
[![Latest version](https://img.shields.io/github/v/release/ghosind/collection?include_prereleases)](https://github.com/ghosind/collection) | ||
![License Badge](https://img.shields.io/github/license/ghosind/collection) | ||
[![Go Reference](https://pkg.go.dev/badge/github.com/ghosind/collection.svg)](https://pkg.go.dev/github.com/ghosind/collection) | ||
|
||
Generics collections framework for Golang. | ||
|
||
> IMPORTANT NOTICE: This package requires Go version 1.18+. | ||
## Overview | ||
|
||
This package provides the following data structure interfaces and implementations: | ||
|
||
- `Collection`: The root interface of most of the structures in this package. | ||
|
||
- `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. | ||
|
||
## Installation | ||
|
||
You can install this package by the following command. | ||
|
||
```sh | ||
go get -u github.com/ghosind/collection | ||
``` | ||
|
||
After installation, you can import it by the following code. | ||
|
||
```go | ||
import "github.com/ghosind/collection" | ||
``` | ||
|
||
## Examples | ||
|
||
### HashSet Examples | ||
|
||
Create a string set, add and test elements in the set. | ||
|
||
```go | ||
fruits := collection.NewHashSet[string]() | ||
|
||
fruits.Add("Apple") | ||
fruits.Add("Banana") | ||
|
||
log.Print(fruits.Contains("Banana")) // true | ||
log.Print(fruits.Contains("Lemon")) | ||
``` |