A go-library includes several customized implementation data structure, keep updating.
v1.2.0
go get github.com/iamsad5566/golib
-
priorityQ
- Max Heap
All the elements within the heap are sorted in decreasing order.
- Min Heap
All the elements within the heap are sorted in increasing order.
- Methods:
- Push(i interface{})
add new element into the heap.
- Pop(): interface{}
return the min/max element from the min/max heap and remove.
- Len(): int
return the size of the heap.
- Push(i interface{})
- Max Heap
-
set
Set stores the input elements, it's an unordered structure, and does not store duplicate elements
- Methods:
- Add(T)
- Remove(): bool
- Len(): int
- Next(): int, err
- Methods:
-
slice
Slice includes a method, Contains so far
- Methods:
- Contains(T): bool
return a boolean value showing whether the slice contains the input value.
- Methods:
-
stack, queue
stack: FILO, queue: FIFO
stack methods:
- Push(T)
- Pop(): T
- IsEmpty(): bool
- Len(): int
queue methods:
- Add(T)
- Poll(): T
- IsEmpty(): bool
- Len(): int