Compare commits

..

No commits in common. 'master' and 'development' have entirely different histories.

@ -1,8 +1,6 @@
language: go language: go
arch:
- amd64
- ppc64le
go: go:
- 1.1.x
- 1.2.x - 1.2.x
- 1.3.x - 1.3.x
- 1.4.x - 1.4.x
@ -10,18 +8,4 @@ go:
- 1.6.x - 1.6.x
- 1.7.x - 1.7.x
- 1.8.x - 1.8.x
- 1.9.x
- 1.10.x
- 1.11.x
- 1.12.x
- 1.13.x
- 1.14.x
- tip - tip
jobs:
exclude: # Excluded for power support as the lower versions are not supported
- arch: ppc64le
go: 1.2.x
- arch: ppc64le
go: 1.3.x
- arch: ppc64le
go: 1.4.x

@ -460,7 +460,7 @@ func main() {
#### TreeMap #### TreeMap
A [map](#maps) based on [red-black tree](#redblacktree). Keys are ordered with respect to the [comparator](#comparator). A [map](#maps) based on [red-black tree](#redblacktree). Keys are ordered ordered with respect to the [comparator](#comparator).
Implements [Map](#maps), [IteratorWithKey](#iteratorwithkey), [EnumerableWithKey](#enumerablewithkey), [JSONSerializer](#jsonserializer) and [JSONDeserializer](#jsondeserializer) interfaces. Implements [Map](#maps), [IteratorWithKey](#iteratorwithkey), [EnumerableWithKey](#enumerablewithkey), [JSONSerializer](#jsonserializer) and [JSONDeserializer](#jsondeserializer) interfaces.
@ -770,15 +770,14 @@ func main() {
_ = tree.Values() // []interface {}{"a", "b", "c", "d", "e", "f", "g"} (in order) _ = tree.Values() // []interface {}{"a", "b", "c", "d", "e", "f", "g"} (in order)
_ = tree.Keys() // []interface {}{1, 2, 3, 4, 5, 6, 7} (in order) _ = tree.Keys() // []interface {}{1, 2, 3, 4, 5, 6, 7} (in order)
tree.Remove(2) // 1->a, 3->c, 4->d, 5->e, 6->f, 7->g (in order) tree.Remove(2) // 1->a, 3->c, 4->d, 5->e, 6->f (in order)
fmt.Println(tree) fmt.Println(tree)
// BTree // BTree
// 1 // 1
// 3 // 3
// 4 // 4
// 5 // 5
// 6 // 6
// 7
tree.Clear() // empty tree.Clear() // empty
tree.Empty() // true tree.Empty() // true

@ -125,7 +125,7 @@ func TestListSwap(t *testing.T) {
list.Add("b", "c") list.Add("b", "c")
list.Swap(0, 1) list.Swap(0, 1)
if actualValue, ok := list.Get(0); actualValue != "b" || !ok { if actualValue, ok := list.Get(0); actualValue != "b" || !ok {
t.Errorf("Got %v expected %v", actualValue, "b") t.Errorf("Got %v expected %v", actualValue, "c")
} }
} }

@ -22,7 +22,7 @@ func assertMapImplementation() {
var _ maps.Map = (*Map)(nil) var _ maps.Map = (*Map)(nil)
} }
// Map holds the elements in a regular hash table, and uses doubly-linked list to store key ordering. // Map holds the elements in a red-black tree
type Map struct { type Map struct {
table map[interface{}]interface{} table map[interface{}]interface{}
ordering *doublylinkedlist.List ordering *doublylinkedlist.List

@ -28,11 +28,6 @@ func (tree *Tree) Iterator() Iterator {
return Iterator{tree: tree, node: nil, position: begin} return Iterator{tree: tree, node: nil, position: begin}
} }
// IteratorAt returns a stateful iterator whose elements are key/value pairs that is initialised at a particular node.
func (tree *Tree) IteratorAt(node *Node) Iterator {
return Iterator{tree: tree, node: node, position: between}
}
// Next moves the iterator to the next element and returns true if there was a next element in the container. // Next moves the iterator to the next element and returns true if there was a next element in the container.
// If Next() returns true, then next element's key and value can be retrieved by Key() and Value(). // If Next() returns true, then next element's key and value can be retrieved by Key() and Value().
// If Next() was called for the first time, then it will point the iterator to the first element if it exists. // If Next() was called for the first time, then it will point the iterator to the first element if it exists.

@ -16,31 +16,31 @@ import (
// ToString converts a value to string. // ToString converts a value to string.
func ToString(value interface{}) string { func ToString(value interface{}) string {
switch value := value.(type) { switch value.(type) {
case string: case string:
return value return value.(string)
case int8: case int8:
return strconv.FormatInt(int64(value), 10) return strconv.FormatInt(int64(value.(int8)), 10)
case int16: case int16:
return strconv.FormatInt(int64(value), 10) return strconv.FormatInt(int64(value.(int16)), 10)
case int32: case int32:
return strconv.FormatInt(int64(value), 10) return strconv.FormatInt(int64(value.(int32)), 10)
case int64: case int64:
return strconv.FormatInt(int64(value), 10) return strconv.FormatInt(int64(value.(int64)), 10)
case uint8: case uint8:
return strconv.FormatUint(uint64(value), 10) return strconv.FormatUint(uint64(value.(uint8)), 10)
case uint16: case uint16:
return strconv.FormatUint(uint64(value), 10) return strconv.FormatUint(uint64(value.(uint16)), 10)
case uint32: case uint32:
return strconv.FormatUint(uint64(value), 10) return strconv.FormatUint(uint64(value.(uint32)), 10)
case uint64: case uint64:
return strconv.FormatUint(uint64(value), 10) return strconv.FormatUint(uint64(value.(uint64)), 10)
case float32: case float32:
return strconv.FormatFloat(float64(value), 'g', -1, 64) return strconv.FormatFloat(float64(value.(float32)), 'g', -1, 64)
case float64: case float64:
return strconv.FormatFloat(float64(value), 'g', -1, 64) return strconv.FormatFloat(float64(value.(float64)), 'g', -1, 64)
case bool: case bool:
return strconv.FormatBool(value) return strconv.FormatBool(value.(bool))
default: default:
return fmt.Sprintf("%+v", value) return fmt.Sprintf("%+v", value)
} }

@ -74,7 +74,7 @@ func TestToStringFloats(t *testing.T) {
if actualValue, expectedValue := ToString(value), "1.123456"; !strings.HasPrefix(actualValue, expectedValue) { if actualValue, expectedValue := ToString(value), "1.123456"; !strings.HasPrefix(actualValue, expectedValue) {
t.Errorf("Got %v expected %v", actualValue, expectedValue) t.Errorf("Got %v expected %v", actualValue, expectedValue)
} }
value = float64(1.123456) value = float32(1.123456)
if actualValue, expectedValue := ToString(value), "1.123456"; !strings.HasPrefix(actualValue, expectedValue) { if actualValue, expectedValue := ToString(value), "1.123456"; !strings.HasPrefix(actualValue, expectedValue) {
t.Errorf("Got %v expected %v", actualValue, expectedValue) t.Errorf("Got %v expected %v", actualValue, expectedValue)
} }

Loading…
Cancel
Save