Compare commits

..

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

@ -1,8 +1,6 @@
language: go
arch:
- amd64
- ppc64le
go:
- 1.1.x
- 1.2.x
- 1.3.x
- 1.4.x
@ -10,18 +8,4 @@ go:
- 1.6.x
- 1.7.x
- 1.8.x
- 1.9.x
- 1.10.x
- 1.11.x
- 1.12.x
- 1.13.x
- 1.14.x
- 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
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.
@ -770,7 +770,7 @@ func main() {
_ = 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.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)
// BTree
// 1
@ -778,7 +778,6 @@ func main() {
// 4
// 5
// 6
// 7
tree.Clear() // empty
tree.Empty() // true

@ -125,7 +125,7 @@ func TestListSwap(t *testing.T) {
list.Add("b", "c")
list.Swap(0, 1)
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)
}
// 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 {
table map[interface{}]interface{}
ordering *doublylinkedlist.List

@ -28,11 +28,6 @@ func (tree *Tree) Iterator() Iterator {
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.
// 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.

@ -16,31 +16,31 @@ import (
// ToString converts a value to string.
func ToString(value interface{}) string {
switch value := value.(type) {
switch value.(type) {
case string:
return value
return value.(string)
case int8:
return strconv.FormatInt(int64(value), 10)
return strconv.FormatInt(int64(value.(int8)), 10)
case int16:
return strconv.FormatInt(int64(value), 10)
return strconv.FormatInt(int64(value.(int16)), 10)
case int32:
return strconv.FormatInt(int64(value), 10)
return strconv.FormatInt(int64(value.(int32)), 10)
case int64:
return strconv.FormatInt(int64(value), 10)
return strconv.FormatInt(int64(value.(int64)), 10)
case uint8:
return strconv.FormatUint(uint64(value), 10)
return strconv.FormatUint(uint64(value.(uint8)), 10)
case uint16:
return strconv.FormatUint(uint64(value), 10)
return strconv.FormatUint(uint64(value.(uint16)), 10)
case uint32:
return strconv.FormatUint(uint64(value), 10)
return strconv.FormatUint(uint64(value.(uint32)), 10)
case uint64:
return strconv.FormatUint(uint64(value), 10)
return strconv.FormatUint(uint64(value.(uint64)), 10)
case float32:
return strconv.FormatFloat(float64(value), 'g', -1, 64)
return strconv.FormatFloat(float64(value.(float32)), 'g', -1, 64)
case float64:
return strconv.FormatFloat(float64(value), 'g', -1, 64)
return strconv.FormatFloat(float64(value.(float64)), 'g', -1, 64)
case bool:
return strconv.FormatBool(value)
return strconv.FormatBool(value.(bool))
default:
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) {
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) {
t.Errorf("Got %v expected %v", actualValue, expectedValue)
}

Loading…
Cancel
Save