Skip to content

Commit

Permalink
Fix README
Browse files Browse the repository at this point in the history
  • Loading branch information
otaviog committed Apr 24, 2022
1 parent 04a7e3d commit 423c00d
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Go Heap

This is a simple implementation of a heap data structure using Go and its generics. Not intend for production.
This is a simple implementation of a heap data structure using Go and its generics.
Not intend for production.

## Usage

Install:

```shell
go get https://github.com/otaviog/goheap
go get github.com/otaviog/goheap
```

Create a new heap:
Expand Down Expand Up @@ -40,34 +41,33 @@ HeapSort(unorderedSlice)
Usage with custom types:

```go
type Person struct {
age int
name string
phone string
}
var persons = []Person{
{
age: 45,
name: "Julius",
phone: "555-5755",
},
{
age: 12,
name: "Cris",
phone: "555-2121",
},
{
age: 42,
name: "Rochele",
phone: "555-4421",
},
}

heap := MakeHeap(persons, func(p1, p2 Person) bool {
return p1.age < p2.age
})
heap.Insert(Person{age: 13, name: "Vicent", phone: "555-4211"})
person, _ := heap.Remove()
type Person struct {
age int
name string
phone string
}
var persons = []Person{
{
age: 45,
name: "Julius",
phone: "555-5755",
},
{
age: 12,
name: "Cris",
phone: "555-2121",
},
{
age: 42,
name: "Rochele",
phone: "555-4421",
},
}
heap := MakeHeap(persons, func(p1, p2 Person) bool {
return p1.age < p2.age
})
heap.Insert(Person{age: 13, name: "Vicent", phone: "555-4211"})
person, _ := heap.Remove()
```

# Benchmarks
Expand Down

0 comments on commit 423c00d

Please sign in to comment.