skl.go
func NewSkiplist(arena *Arena) *Skiplist {
	// Allocate head and tail nodes.
	head, err := newNode(arena, maxHeight)
	if err != nil {
		panic("arenaSize is not large enough to hold the head node")
	}

	tail, err := newNode(arena, maxHeight)
	if err != nil {
		panic("arenaSize is not large enough to hold the tail node")
	}

	// Link all head/tail levels together.
	headOffset := arena.GetPointerOffset(unsafe.Pointer(head))
	tailOffset := arena.GetPointerOffset(unsafe.Pointer(tail))
	for i := 0; i < maxHeight; i++ {
		head.tower[i].nextOffset = tailOffset
		tail.tower[i].prevOffset = headOffset
	}

	skl := &Skiplist{
		arena:  arena,
		head:   head,
		tail:   tail,
		height: 1,
	}

	return skl
}
func NewSkiplist(arena *Arena) *Skiplist {
	// Allocate head and tail nodes.
	head, err := newNode(arena, maxHeight)
	if err != nil {
		panic("arenaSize is not large enough to hold the head node")
	}

	tail, err := newNode(arena, maxHeight)
	if err != nil {
		panic("arenaSize is not large enough to hold the tail node")
	}

	// Link all head/tail levels together.
	headOffset := arena.GetPointerOffset(unsafe.Pointer(head))
	tailOffset := arena.GetPointerOffset(unsafe.Pointer(tail))
	for i := 0; i < maxHeight; i++ {
		head.tower[i].nextOffset = tailOffset
		tail.tower[i].prevOffset = headOffset
	}

	skl := &Skiplist{
		arena:  arena,
		head:   head,
		tail:   tail,
		height: 1,
	}

	return skl
}
func NewSkiplist ( arena * Arena ) * Skiplist { // Allocate head and tail nodes. head , err := newNode ( arena , maxHeight ) if err != nil { panic ( " " ) } tail , err := newNode ( arena , maxHeight ) if err != nil { panic ( " " ) } // Link all head/tail levels together. headOffset := arena . GetPointerOffset ( unsafe . Pointer ( head ) ) tailOffset := arena . GetPointerOffset ( unsafe . Pointer ( tail ) ) for i := 0 ; i < maxHeight ; i ++ { head . tower [ i ] . nextOffset = tailOffset tail . tower [ i ] . prevOffset = headOffset } skl := & Skiplist { arena : arena , head : head , tail : tail , height : 1 , } return skl }
// NewSkiplist constructs and initializes a new, empty skiplist. All nodes, keys,
// and values in the skiplist will be allocated from the given arena.
NewSkiplist constructs and initializes a new empty skiplist . All nodes keys and values in the skiplist will be allocated from the given arena .