-
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.
implementation complete,added working tests
- Loading branch information
1 parent
86f305b
commit bbb2ccf
Showing
9 changed files
with
474 additions
and
355 deletions.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
.vscode |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
// just prints the skiplist | ||
func skiplist_debug(a *skiplist) { | ||
level := a.n_levels - 1 | ||
finger := a.head | ||
|
||
for ; level >= 0; level-- { | ||
counter := 0 | ||
if finger.next[level] == nil { | ||
fmt.Print(nil) | ||
} | ||
for node := finger.next[level]; node != nil; node = node.next[level] { | ||
counter++ | ||
fmt.Print(" ", node.value) | ||
} | ||
fmt.Println(" nil", counter) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main | ||
|
||
import ( | ||
"math/rand" | ||
"time" | ||
) | ||
|
||
const Mask = ((1 << SKIPLIST_MAX_LEVEL) - 1) | ||
|
||
func coin_tosses(prob float64, max_levels int) (counter int) { | ||
t1 := time.Now() | ||
|
||
counter = 1 | ||
|
||
res_mask := rand.Uint64() & Mask | ||
// find first zero in float representation | ||
for ; res_mask&1 == 0; res_mask >>= 1 { | ||
counter++ | ||
} | ||
|
||
//res := rand.Float64() | ||
//for res < prob { | ||
// res = rand.Float64() | ||
// counter++ | ||
//} | ||
|
||
randtime += time.Now().Sub(t1) | ||
return counter | ||
|
||
} |
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
Oops, something went wrong.