optimise LatestMap.Merge by merging old into young

This commit is contained in:
Matthias Radestock
2016-08-23 19:34:05 +01:00
parent e8ebb31075
commit c50155bb7e
3 changed files with 51 additions and 6 deletions

View File

@@ -42,6 +42,9 @@ type Map interface {
// This operation is O(log N) in the number of keys.
Lookup(key string) (interface{}, bool)
// First returns the "first" value in the map, if any, or nil.
First() interface{}
// Size returns the number of key value pairs in the map.
// This takes O(1) time.
Size() int
@@ -348,6 +351,10 @@ func lookupLowLevel(self *tree, partialHash, hash uint64) (interface{}, bool) {
return self.value, true
}
func (m *tree) First() interface{} {
return m.value
}
func (m *tree) Size() int {
return m.count
}