From 80b629916a1e21cfb0abf0da6fe25d3280b5a4fc Mon Sep 17 00:00:00 2001 From: John Date: Wed, 2 Dec 2020 21:38:29 +0800 Subject: [PATCH] fix issue in function Clone for package gmap/garray/gtree --- container/garray/garray_normal_any.go | 2 +- container/garray/garray_normal_int.go | 2 +- container/garray/garray_normal_str.go | 2 +- container/garray/garray_sorted_any.go | 2 +- container/garray/garray_sorted_int.go | 2 +- container/garray/garray_sorted_str.go | 2 +- container/gmap/gmap_hash_int_any_map.go | 2 +- container/gmap/gmap_hash_int_int_map.go | 2 +- container/gmap/gmap_hash_int_str_map.go | 2 +- container/gmap/gmap_hash_str_any_map.go | 2 +- container/gmap/gmap_hash_str_int_map.go | 2 +- container/gmap/gmap_hash_str_str_map.go | 2 +- container/gtree/gtree_avltree.go | 6 +++--- container/gtree/gtree_btree.go | 2 +- container/gtree/gtree_redblacktree.go | 6 +++--- 15 files changed, 19 insertions(+), 19 deletions(-) diff --git a/container/garray/garray_normal_any.go b/container/garray/garray_normal_any.go index 2ec882819..4c41cc2d4 100644 --- a/container/garray/garray_normal_any.go +++ b/container/garray/garray_normal_any.go @@ -453,7 +453,7 @@ func (a *Array) Clone() (newArray *Array) { array := make([]interface{}, len(a.array)) copy(array, a.array) a.mu.RUnlock() - return NewArrayFrom(array, !a.mu.IsSafe()) + return NewArrayFrom(array, a.mu.IsSafe()) } // Clear deletes all items of current array. diff --git a/container/garray/garray_normal_int.go b/container/garray/garray_normal_int.go index ef13c8851..69d4c157a 100644 --- a/container/garray/garray_normal_int.go +++ b/container/garray/garray_normal_int.go @@ -469,7 +469,7 @@ func (a *IntArray) Clone() (newArray *IntArray) { array := make([]int, len(a.array)) copy(array, a.array) a.mu.RUnlock() - return NewIntArrayFrom(array, !a.mu.IsSafe()) + return NewIntArrayFrom(array, a.mu.IsSafe()) } // Clear deletes all items of current array. diff --git a/container/garray/garray_normal_str.go b/container/garray/garray_normal_str.go index 4d3f27b8b..889a19a09 100644 --- a/container/garray/garray_normal_str.go +++ b/container/garray/garray_normal_str.go @@ -457,7 +457,7 @@ func (a *StrArray) Clone() (newArray *StrArray) { array := make([]string, len(a.array)) copy(array, a.array) a.mu.RUnlock() - return NewStrArrayFrom(array, !a.mu.IsSafe()) + return NewStrArrayFrom(array, a.mu.IsSafe()) } // Clear deletes all items of current array. diff --git a/container/garray/garray_sorted_any.go b/container/garray/garray_sorted_any.go index 030840f11..3122be023 100644 --- a/container/garray/garray_sorted_any.go +++ b/container/garray/garray_sorted_any.go @@ -499,7 +499,7 @@ func (a *SortedArray) Clone() (newArray *SortedArray) { array := make([]interface{}, len(a.array)) copy(array, a.array) a.mu.RUnlock() - return NewSortedArrayFrom(array, a.comparator, !a.mu.IsSafe()) + return NewSortedArrayFrom(array, a.comparator, a.mu.IsSafe()) } // Clear deletes all items of current array. diff --git a/container/garray/garray_sorted_int.go b/container/garray/garray_sorted_int.go index 3153c9cd5..fa44ed534 100644 --- a/container/garray/garray_sorted_int.go +++ b/container/garray/garray_sorted_int.go @@ -496,7 +496,7 @@ func (a *SortedIntArray) Clone() (newArray *SortedIntArray) { array := make([]int, len(a.array)) copy(array, a.array) a.mu.RUnlock() - return NewSortedIntArrayFrom(array, !a.mu.IsSafe()) + return NewSortedIntArrayFrom(array, a.mu.IsSafe()) } // Clear deletes all items of current array. diff --git a/container/garray/garray_sorted_str.go b/container/garray/garray_sorted_str.go index 9e23da894..762017d72 100644 --- a/container/garray/garray_sorted_str.go +++ b/container/garray/garray_sorted_str.go @@ -498,7 +498,7 @@ func (a *SortedStrArray) Clone() (newArray *SortedStrArray) { array := make([]string, len(a.array)) copy(array, a.array) a.mu.RUnlock() - return NewSortedStrArrayFrom(array, !a.mu.IsSafe()) + return NewSortedStrArrayFrom(array, a.mu.IsSafe()) } // Clear deletes all items of current array. diff --git a/container/gmap/gmap_hash_int_any_map.go b/container/gmap/gmap_hash_int_any_map.go index fa9541867..52df0cebc 100644 --- a/container/gmap/gmap_hash_int_any_map.go +++ b/container/gmap/gmap_hash_int_any_map.go @@ -56,7 +56,7 @@ func (m *IntAnyMap) Iterator(f func(k int, v interface{}) bool) { // Clone returns a new hash map with copy of current map data. func (m *IntAnyMap) Clone() *IntAnyMap { - return NewIntAnyMapFrom(m.MapCopy(), !m.mu.IsSafe()) + return NewIntAnyMapFrom(m.MapCopy(), m.mu.IsSafe()) } // Map returns the underlying data map. diff --git a/container/gmap/gmap_hash_int_int_map.go b/container/gmap/gmap_hash_int_int_map.go index 86c95cb8f..4d546661e 100644 --- a/container/gmap/gmap_hash_int_int_map.go +++ b/container/gmap/gmap_hash_int_int_map.go @@ -54,7 +54,7 @@ func (m *IntIntMap) Iterator(f func(k int, v int) bool) { // Clone returns a new hash map with copy of current map data. func (m *IntIntMap) Clone() *IntIntMap { - return NewIntIntMapFrom(m.MapCopy(), !m.mu.IsSafe()) + return NewIntIntMapFrom(m.MapCopy(), m.mu.IsSafe()) } // Map returns the underlying data map. diff --git a/container/gmap/gmap_hash_int_str_map.go b/container/gmap/gmap_hash_int_str_map.go index 4c6078f2b..8d1f1edfd 100644 --- a/container/gmap/gmap_hash_int_str_map.go +++ b/container/gmap/gmap_hash_int_str_map.go @@ -54,7 +54,7 @@ func (m *IntStrMap) Iterator(f func(k int, v string) bool) { // Clone returns a new hash map with copy of current map data. func (m *IntStrMap) Clone() *IntStrMap { - return NewIntStrMapFrom(m.MapCopy(), !m.mu.IsSafe()) + return NewIntStrMapFrom(m.MapCopy(), m.mu.IsSafe()) } // Map returns the underlying data map. diff --git a/container/gmap/gmap_hash_str_any_map.go b/container/gmap/gmap_hash_str_any_map.go index b0323649c..423923e2c 100644 --- a/container/gmap/gmap_hash_str_any_map.go +++ b/container/gmap/gmap_hash_str_any_map.go @@ -56,7 +56,7 @@ func (m *StrAnyMap) Iterator(f func(k string, v interface{}) bool) { // Clone returns a new hash map with copy of current map data. func (m *StrAnyMap) Clone() *StrAnyMap { - return NewStrAnyMapFrom(m.MapCopy(), !m.mu.IsSafe()) + return NewStrAnyMapFrom(m.MapCopy(), m.mu.IsSafe()) } // Map returns the underlying data map. diff --git a/container/gmap/gmap_hash_str_int_map.go b/container/gmap/gmap_hash_str_int_map.go index b0af9f967..58f98f017 100644 --- a/container/gmap/gmap_hash_str_int_map.go +++ b/container/gmap/gmap_hash_str_int_map.go @@ -54,7 +54,7 @@ func (m *StrIntMap) Iterator(f func(k string, v int) bool) { // Clone returns a new hash map with copy of current map data. func (m *StrIntMap) Clone() *StrIntMap { - return NewStrIntMapFrom(m.MapCopy(), !m.mu.IsSafe()) + return NewStrIntMapFrom(m.MapCopy(), m.mu.IsSafe()) } // Map returns the underlying data map. diff --git a/container/gmap/gmap_hash_str_str_map.go b/container/gmap/gmap_hash_str_str_map.go index 78c14e192..5565b28a7 100644 --- a/container/gmap/gmap_hash_str_str_map.go +++ b/container/gmap/gmap_hash_str_str_map.go @@ -55,7 +55,7 @@ func (m *StrStrMap) Iterator(f func(k string, v string) bool) { // Clone returns a new hash map with copy of current map data. func (m *StrStrMap) Clone() *StrStrMap { - return NewStrStrMapFrom(m.MapCopy(), !m.mu.IsSafe()) + return NewStrStrMapFrom(m.MapCopy(), m.mu.IsSafe()) } // Map returns the underlying data map. diff --git a/container/gtree/gtree_avltree.go b/container/gtree/gtree_avltree.go index 028e19850..eb8e72d05 100644 --- a/container/gtree/gtree_avltree.go +++ b/container/gtree/gtree_avltree.go @@ -56,7 +56,7 @@ func NewAVLTreeFrom(comparator func(v1, v2 interface{}) int, data map[interface{ // Clone returns a new tree with a copy of current tree. func (tree *AVLTree) Clone() *AVLTree { - newTree := NewAVLTree(tree.comparator, !tree.mu.IsSafe()) + newTree := NewAVLTree(tree.comparator, tree.mu.IsSafe()) newTree.Sets(tree.Map()) return newTree } @@ -441,9 +441,9 @@ func (tree *AVLTree) MapStrAny() map[string]interface{} { func (tree *AVLTree) Flip(comparator ...func(v1, v2 interface{}) int) { t := (*AVLTree)(nil) if len(comparator) > 0 { - t = NewAVLTree(comparator[0], !tree.mu.IsSafe()) + t = NewAVLTree(comparator[0], tree.mu.IsSafe()) } else { - t = NewAVLTree(tree.comparator, !tree.mu.IsSafe()) + t = NewAVLTree(tree.comparator, tree.mu.IsSafe()) } tree.IteratorAsc(func(key, value interface{}) bool { t.put(value, key, nil, &t.root) diff --git a/container/gtree/gtree_btree.go b/container/gtree/gtree_btree.go index febc8ec9a..a8c1bbb3b 100644 --- a/container/gtree/gtree_btree.go +++ b/container/gtree/gtree_btree.go @@ -68,7 +68,7 @@ func NewBTreeFrom(m int, comparator func(v1, v2 interface{}) int, data map[inter // Clone returns a new tree with a copy of current tree. func (tree *BTree) Clone() *BTree { - newTree := NewBTree(tree.m, tree.comparator, !tree.mu.IsSafe()) + newTree := NewBTree(tree.m, tree.comparator, tree.mu.IsSafe()) newTree.Sets(tree.Map()) return newTree } diff --git a/container/gtree/gtree_redblacktree.go b/container/gtree/gtree_redblacktree.go index c464889b4..f73c9e568 100644 --- a/container/gtree/gtree_redblacktree.go +++ b/container/gtree/gtree_redblacktree.go @@ -83,7 +83,7 @@ func (tree *RedBlackTree) SetComparator(comparator func(a, b interface{}) int) { // Clone returns a new tree with a copy of current tree. func (tree *RedBlackTree) Clone() *RedBlackTree { - newTree := NewRedBlackTree(tree.comparator, !tree.mu.IsSafe()) + newTree := NewRedBlackTree(tree.comparator, tree.mu.IsSafe()) newTree.Sets(tree.Map()) return newTree } @@ -656,9 +656,9 @@ func (tree *RedBlackTree) Search(key interface{}) (value interface{}, found bool func (tree *RedBlackTree) Flip(comparator ...func(v1, v2 interface{}) int) { t := (*RedBlackTree)(nil) if len(comparator) > 0 { - t = NewRedBlackTree(comparator[0], !tree.mu.IsSafe()) + t = NewRedBlackTree(comparator[0], tree.mu.IsSafe()) } else { - t = NewRedBlackTree(tree.comparator, !tree.mu.IsSafe()) + t = NewRedBlackTree(tree.comparator, tree.mu.IsSafe()) } tree.IteratorAsc(func(key, value interface{}) bool { t.doSet(value, key)