lazifying

This commit is contained in:
Jae Kwon
2014-05-21 21:48:41 -07:00
parent 850144f3e7
commit f66c552ef2
4 changed files with 171 additions and 108 deletions

View File

@ -5,43 +5,46 @@ import (
)
type Value interface {
Bytes() []byte
Bytes() []byte
}
type Key interface {
Equals(b Key) bool
Less(b Key) bool
Bytes() []byte
Equals(b Key) bool
Less(b Key) bool
Bytes() []byte
}
type Tree interface {
Root() Node
Root() Node
Size() int
Has(key Key) bool
Get(key Key) (value Value, err error)
Hash() ([]byte, int)
Size() uint64
Height() uint8
Has(key Key) bool
Get(key Key) (Value, error)
Hash() ([]byte, uint64)
Put(key Key, value Value) (err error)
Remove(key Key) (value Value, err error)
Put(Key, Value) (err error)
Remove(Key) (Value, error)
}
type Node interface {
Key() Key
Value() Value
Left() Node
Right() Node
Key() Key
Value() Value
Left() Node
Right() Node
Size() int
Has(key Key) bool
Get(key Key) (value Value, err error)
Hash() ([]byte, int)
Size() uint64
Height() uint8
Has(Key) bool
Get(Key) (Value, error)
Hash() ([]byte, uint64)
Bytes() []byte
Put(key Key, value Value) (_ *IAVLNode, updated bool)
Remove(key Key) (_ *IAVLNode, value Value, err error)
Put(Key, Value) (*IAVLNode, bool)
Remove(Key) (*IAVLNode, Value, error)
}
type NodeIterator func() (node Node)
type NodeIterator func() Node
func NotFound(key Key) error {
return fmt.Errorf("Key was not found.")