|
@ -8,7 +8,6 @@ package bptree |
|
|
*/ |
|
|
*/ |
|
|
type BpTree struct { |
|
|
type BpTree struct { |
|
|
root *BpNode |
|
|
root *BpNode |
|
|
size int |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type loc_iterator func() (i int, leaf *BpNode, li loc_iterator) |
|
|
type loc_iterator func() (i int, leaf *BpNode, li loc_iterator) |
|
@ -16,14 +15,9 @@ type loc_iterator func() (i int, leaf *BpNode, li loc_iterator) |
|
|
func NewBpTree(node_size int) *BpTree { |
|
|
func NewBpTree(node_size int) *BpTree { |
|
|
return &BpTree{ |
|
|
return &BpTree{ |
|
|
root: NewLeaf(node_size, false), |
|
|
root: NewLeaf(node_size, false), |
|
|
size: 0, |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (self *BpTree) Size() int { |
|
|
|
|
|
return self.size |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (self *BpTree) Has(key Hashable) bool { |
|
|
func (self *BpTree) Has(key Hashable) bool { |
|
|
if len(self.root.keys) == 0 { |
|
|
if len(self.root.keys) == 0 { |
|
|
return false |
|
|
return false |
|
@ -52,7 +46,6 @@ func (self *BpTree) Add(key Hashable, value interface{}) (err error) { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
self.root = new_root |
|
|
self.root = new_root |
|
|
self.size += 1 |
|
|
|
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -100,7 +93,6 @@ func (self *BpTree) RemoveWhere(key Hashable, where WhereFunc) (err error) { |
|
|
} else { |
|
|
} else { |
|
|
self.root = new_root |
|
|
self.root = new_root |
|
|
} |
|
|
} |
|
|
self.size -= 1 |
|
|
|
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|