FAQ
Nice work.

Using this slightly altered intNode defintion:

type intNode struct {
  val int
  left, right *intNode
  color sset.Color
}

func (z intNode) Cmp(nd sset.Node) int { return z.val - nd.(*intNode).val }
func (z intNode) Left() (nd sset.Node, ok bool) { return z.left, z.left != nil }
func (z intNode) Right() (nd sset.Node, ok bool) { return z.right, z.right != nil }
func (z *intNode) SetLeft(nd sset.Node) { (*z).left = nd.(*intNode) }
func (z *intNode) SetRight(nd sset.Node) { (*z).right = nd.(*intNode) }
func (z intNode) Color() sset.Color { return z.color }
func (z *intNode) SetColor(cl sset.Color) { (*z).color = cl }
func (z *intNode) SetValue(nd sset.Node) { z.val = nd.(*intNode).val }


BenchmarkInsert 1000000 1211 ns/op
BenchmarkGet 5000000 554 ns/op

BenchmarkInsertSSet 5000000 476 ns/op
BenchmarkGetSSet 10000000 193 ns/op


You're not far off the builtin:

BenchmarkInsertMap 10000000 300 ns/op
BenchmarkGetMap 20000000 130 ns/op

Dan

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 5 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJun 6, '13 at 5:09p
activeJun 7, '13 at 11:18a
posts5
users3
websitegolang.org

People

Translate

site design / logo © 2023 Grokbase