Compare commits

..

26 Commits

Author SHA1 Message Date
Emir Pasic 79df803e55
Merge pull request #147 from nagesh4193/master
Added Power Support ppc64le
5 years ago
nagesh4193 9500fd4d47
Added Power Support ppc64le 5 years ago
nagesh4193 53bbe08825
Added Power Support ppc64le 5 years ago
nagesh4193 d050436156
Added Power Support ppc64le 5 years ago
Emir Pasic 7e23495895
Merge pull request #139 from ably-forks/feature/iterator-at
Create a redblacktree iterator at a specific node
5 years ago
Paul Cruickshank 962a86dc92 Create an iterator at a specific node 5 years ago
Emir Pasic 80e934ed68
Merge pull request #134 from mimiasd/fix-test
- fix some unit test
6 years ago
Emir Pasic 3439eab70c
Add 1.13 and 1.14 versions to tests 6 years ago
yuanjin edc20eca0a - fix arraylist test 6 years ago
yuanjin 3ba27e24d3 - fix utils test 6 years ago
Emir Pasic 4e23915b9a
Merge pull request #124 from stevegt/godsort
rename sort example to godsort to prevent conflict with UNIX 'sort'
6 years ago
Steve Traugott 482308b065 rename sort example to godsort
Closes #123.
6 years ago
Emir Pasic e689965507
Merge pull request #114 from mrvon/master
README: fix BTree commit
6 years ago
dennis 7c93e37d09 README: fix BTree commit 6 years ago
Emir Pasic ab5242f706
Update .travis.yml 6 years ago
Emir Pasic 96361ff183
Merge pull request #104 from own2pwn/patch-1
typo fix
6 years ago
Emir Pasic 00662fa41f
Merge pull request #108 from navigaid/patch-1
fix linkedhashmap.Map comment error
6 years ago
navigaid a733df2d7b
fix linkedhashmap.Map comment error
In linkedhashmap.go there is a line of comment saying "Map holds the elements in a red-black tree", which is not true. The linkedhashmap holds it's elements in a regular hash table, and uses doubly-linked list to store key ordering.
7 years ago
own2pwn 87aa46c680
typo fix 7 years ago
Emir Pasic 729073a73c
Merge pull request #100 from Quasilyte/patch-1
utils: remove excessive type assertions
7 years ago
Iskander (Alex) Sharipov 3978ee8254
utils: remove excessive type assertions
Assign type switch variable to get properly-typed value
inside case clauses.

Signed-off-by: Iskander Sharipov <quasilyte@gmail.com>
7 years ago
Emir Pasic 7c131f6714
Merge pull request #94 from HaraldNordgren/go_versions
Bump Travis versions
7 years ago
Harald Nordgren 7bbe2d9e0b Bump Travis versions 7 years ago
Emir Pasic 1615341f11
Merge pull request #92 from emirpasic/development
TreeMap Floor and Ceiling functions
7 years ago
Emir Pasic 7aedbffbed
Merge pull request #91 from emirpasic/development
LinkedHashMap
7 years ago
Emir Pasic 66ea3cf49c
Merge pull request #90 from emirpasic/development
Sets bulk initialization
7 years ago

@ -1,6 +1,8 @@
language: go
arch:
- amd64
- ppc64le
go:
- 1.1.x
- 1.2.x
- 1.3.x
- 1.4.x
@ -8,4 +10,18 @@ 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 ordered with respect to the [comparator](#comparator).
A [map](#maps) based on [red-black tree](#redblacktree). Keys are 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 (in order)
tree.Remove(2) // 1->a, 3->c, 4->d, 5->e, 6->f, 7->g (in order)
fmt.Println(tree)
// BTree
// 1
@ -778,6 +778,7 @@ 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, "c")
t.Errorf("Got %v expected %v", actualValue, "b")
}
}

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

@ -28,6 +28,11 @@ 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.(type) {
switch value := value.(type) {
case string:
return value.(string)
return value
case int8:
return strconv.FormatInt(int64(value.(int8)), 10)
return strconv.FormatInt(int64(value), 10)
case int16:
return strconv.FormatInt(int64(value.(int16)), 10)
return strconv.FormatInt(int64(value), 10)
case int32:
return strconv.FormatInt(int64(value.(int32)), 10)
return strconv.FormatInt(int64(value), 10)
case int64:
return strconv.FormatInt(int64(value.(int64)), 10)
return strconv.FormatInt(int64(value), 10)
case uint8:
return strconv.FormatUint(uint64(value.(uint8)), 10)
return strconv.FormatUint(uint64(value), 10)
case uint16:
return strconv.FormatUint(uint64(value.(uint16)), 10)
return strconv.FormatUint(uint64(value), 10)
case uint32:
return strconv.FormatUint(uint64(value.(uint32)), 10)
return strconv.FormatUint(uint64(value), 10)
case uint64:
return strconv.FormatUint(uint64(value.(uint64)), 10)
return strconv.FormatUint(uint64(value), 10)
case float32:
return strconv.FormatFloat(float64(value.(float32)), 'g', -1, 64)
return strconv.FormatFloat(float64(value), 'g', -1, 64)
case float64:
return strconv.FormatFloat(float64(value.(float64)), 'g', -1, 64)
return strconv.FormatFloat(float64(value), 'g', -1, 64)
case bool:
return strconv.FormatBool(value.(bool))
return strconv.FormatBool(value)
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 = float32(1.123456)
value = float64(1.123456)
if actualValue, expectedValue := ToString(value), "1.123456"; !strings.HasPrefix(actualValue, expectedValue) {
t.Errorf("Got %v expected %v", actualValue, expectedValue)
}

Loading…
Cancel
Save