Documentation
¶
Overview ¶
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Index ¶
- func IsSorted[S any, T Comparable[T]](items []S, fn func(S) T) bool
- type AnySortedSet
- func (p *AnySortedSet[T]) Contains(element T) bool
- func (p *AnySortedSet[T]) Find(element T) uint
- func (p *AnySortedSet[T]) Insert(element T)
- func (p *AnySortedSet[T]) InsertSorted(q *AnySortedSet[T])
- func (p *AnySortedSet[T]) Iter() iter.Iterator[T]
- func (p *AnySortedSet[T]) Remove(element T) bool
- func (p *AnySortedSet[T]) ToArray() []T
- type Comparable
- type Order
- type SortedSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsSorted ¶ added in v1.1.17
func IsSorted[S any, T Comparable[T]](items []S, fn func(S) T) bool
IsSorted checks whether a given set of comparable items are in sorted order.
Types ¶
type AnySortedSet ¶
type AnySortedSet[T Comparable[T]] []T
AnySortedSet is an array of unique sorted values (i.e. no duplicates).
func NewAnySortedSet ¶
func NewAnySortedSet[T Comparable[T]](items ...T) *AnySortedSet[T]
NewAnySortedSet creates a sorted set from a given array by first cloning that array, and then sorting it appropriately, etc. This means the given array will not be mutated by this function, or any subsequent calls on the resulting set.
func RawAnySortedSet ¶ added in v1.2.0
func RawAnySortedSet[T Comparable[T]](items ...T) *AnySortedSet[T]
RawAnySortedSet creates a sort set from a given array without first cloning it. That means the array may well be mutated by this function and/or subsequent calls to the resulting set.
func UnionAnySortedSets ¶
func UnionAnySortedSets[S any, T Comparable[T]](elems []S, fn func(S) *AnySortedSet[T]) *AnySortedSet[T]
UnionAnySortedSets unions together a number of things which can be turn into a sorted set using a given mapping function. At some level, this is a map/reduce function.
func (*AnySortedSet[T]) Contains ¶
func (p *AnySortedSet[T]) Contains(element T) bool
Contains returns true if a given element is in the set.
func (*AnySortedSet[T]) Find ¶ added in v1.1.17
func (p *AnySortedSet[T]) Find(element T) uint
Find returns the index of the matching element in this set, or it returns MaxUInt.
func (*AnySortedSet[T]) Insert ¶
func (p *AnySortedSet[T]) Insert(element T)
Insert an element into this sorted set.
func (*AnySortedSet[T]) InsertSorted ¶
func (p *AnySortedSet[T]) InsertSorted(q *AnySortedSet[T])
InsertSorted inserts all elements in a given sorted set into this set.
func (*AnySortedSet[T]) Iter ¶
func (p *AnySortedSet[T]) Iter() iter.Iterator[T]
Iter returns an iterator over the elements of this sorted set.
func (*AnySortedSet[T]) Remove ¶ added in v1.2.0
func (p *AnySortedSet[T]) Remove(element T) bool
Remove an element from this sorted set.
func (*AnySortedSet[T]) ToArray ¶
func (p *AnySortedSet[T]) ToArray() []T
ToArray extracts the underlying array from this sorted set.
type Comparable ¶
type Comparable[T any] interface { // Cmp returns < 0 if this is less than other, or 0 if they are equal, or > // 0 if this is greater than other. Cmp(other T) int }
Comparable provides an interface which types used in a AnySortedSet must implement.
type Order ¶
Order provides a wrapper around primtive types for use with an AnySortedSet. This is mostly for testing purposes.
type SortedSet ¶
SortedSet is an array of unique sorted values (i.e. no duplicates).
func NewSortedSet ¶
NewSortedSet returns an empty sorted set.
func UnionSortedSets ¶
UnionSortedSets unions together a number of things which can be turn into a sorted set using a given mapping function. At some level, this is a map/reduce function.
func (*SortedSet[T]) Insert ¶
func (p *SortedSet[T]) Insert(element T)
Insert an element into this sorted set.
func (*SortedSet[T]) InsertSorted ¶
InsertSorted inserts all elements in a given sorted set into this set.
func (*SortedSet[T]) Intersect ¶ added in v1.1.6
Intersect removes all elements from this set which are not in the given set.