Skip to content

Commit

Permalink
fixed documentation to include import
Browse files Browse the repository at this point in the history
  • Loading branch information
BazookaMusic committed Apr 7, 2019
1 parent b2a5a77 commit fdda806
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ The skiplist acts as a set and supports insert,contains,remove operations in O(l

Example usage:
```golang

import (
sl "github.com/gerrish/goskiplist"
)
// initialise random number generator
rand.Seed(time.Now().UTC().UnixNano())

Expand All @@ -23,22 +27,22 @@ type Int int

// Less : Node comparison function for Int, should be
// set for user struct. Returns true if a is less than b
func (a Int) Less(b SkiplistItem) bool {
func (a Int) Less(b sl.SkiplistItem) bool {
b, ok := b.(Int)

return ok && int(a) < int(b.(Int))
}

// Equals : Node comparison function for Int, should be
// set for user struct. Returns true if a equals b
func (a Int) Equals(b SkiplistItem) bool {
func (a Int) Equals(b sl.SkiplistItem) bool {
b, ok := b.(Int)

return ok && a == b
}

// allocate skiplist struct
head := new(Skiplist)
head := new(sl.Skiplist)


/* Initialise skiplist parameters */
Expand Down Expand Up @@ -95,7 +99,7 @@ for index := 0; index < dataAmount; index++ {
}

/* Union */
var other = new(Skiplist)
var other = new(sl.Skiplist)
other.InitSkiplist(0.5, 30, FAST)

for index := 0; index < 2*dataAmount; index++ {
Expand All @@ -105,7 +109,7 @@ for index := 0; index < 2*dataAmount; index++ {
}

/* new skiplist struct, set parameters */
var union = new(Skiplist)
var union = new(sl.Skiplist)
union.InitSkiplist(0.5, 30, FAST)

/*the union items are inserted anew according to the parameters
Expand All @@ -119,9 +123,9 @@ elements keep their former levels, no random calls.
faster but can lead to unbalanced skiplists.
New skiplist parameters set to defaults, see function
documentation. */
union := UnionSimple(head, other)
union := sl.UnionSimple(head, other)

var intersection = new(Skiplist)
var intersection = new(sl.Skiplist)
intersection.InitSkiplist(0.5, 30, FAST)

/*the intersection items are inserted anew according to the parameters
Expand All @@ -136,7 +140,7 @@ Elements keep their former levels, no random calls.
faster but can lead to unbalanced skiplists.
New skiplist parameters set to defaults, see function
documentation. */
intersection := IntersectionSimple(head, other)
intersection := sl.IntersectionSimple(head, other)



Expand Down

0 comments on commit fdda806

Please sign in to comment.