Documentation
¶
Overview ¶
Copyright 2020- IBM Inc. All Rights Reserved. SPDX-License-Identifier: Apache-2.0
Copyright 2020- IBM Inc. All Rights Reserved. SPDX-License-Identifier: Apache-2.0
Index ¶
- type CanonicalSet
- func (c *CanonicalSet) AddHole(hole Interval)
- func (c *CanonicalSet) AddInterval(v Interval)
- func (c *CanonicalSet) CalculateSize() int64
- func (c *CanonicalSet) ContainedIn(other *CanonicalSet) bool
- func (c *CanonicalSet) Contains(n int64) bool
- func (c *CanonicalSet) Copy() *CanonicalSet
- func (c *CanonicalSet) Elements() []int64
- func (c *CanonicalSet) Equal(other *CanonicalSet) bool
- func (c *CanonicalSet) Intersect(other *CanonicalSet) *CanonicalSet
- func (c *CanonicalSet) Intervals() []Interval
- func (c *CanonicalSet) IsEmpty() bool
- func (c *CanonicalSet) IsSingleNumber() bool
- func (c *CanonicalSet) Min() int64
- func (c *CanonicalSet) NumIntervals() int
- func (c *CanonicalSet) Overlap(other *CanonicalSet) bool
- func (c *CanonicalSet) String() string
- func (c *CanonicalSet) Subtract(other *CanonicalSet) *CanonicalSet
- func (c *CanonicalSet) Union(other *CanonicalSet) *CanonicalSet
- type Interval
- func (i Interval) Elements() []int64
- func (i Interval) End() int64
- func (i Interval) Equal(x Interval) bool
- func (i Interval) IsEmpty() bool
- func (i Interval) ShortString() string
- func (i Interval) Size() int64
- func (i Interval) Start() int64
- func (i Interval) String() string
- func (i Interval) ToSet() *CanonicalSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CanonicalSet ¶
type CanonicalSet struct {
// contains filtered or unexported fields
}
CanonicalSet is a set of int64 integers, implemented using an ordered slice of non-overlapping, non-touching interval
func NewCanonicalSet ¶
func NewCanonicalSet() *CanonicalSet
func NewSetFromInterval ¶
func NewSetFromInterval(span Interval) *CanonicalSet
func (*CanonicalSet) AddHole ¶
func (c *CanonicalSet) AddHole(hole Interval)
AddHole updates the current CanonicalSet object by removing the input Interval from the set
func (*CanonicalSet) AddInterval ¶
func (c *CanonicalSet) AddInterval(v Interval)
AddInterval adds a new interval range to the set
func (*CanonicalSet) CalculateSize ¶ added in v0.3.0
func (c *CanonicalSet) CalculateSize() int64
func (*CanonicalSet) ContainedIn ¶
func (c *CanonicalSet) ContainedIn(other *CanonicalSet) bool
ContainedIn returns true of the current CanonicalSet is contained in the input CanonicalSet
func (*CanonicalSet) Contains ¶
func (c *CanonicalSet) Contains(n int64) bool
func (*CanonicalSet) Copy ¶
func (c *CanonicalSet) Copy() *CanonicalSet
Copy returns a new copy of the CanonicalSet object
func (*CanonicalSet) Elements ¶ added in v0.3.0
func (c *CanonicalSet) Elements() []int64
Elements returns a slice with all the numbers contained in the set. USE WITH CARE. It can easily run out of memory for large sets.
func (*CanonicalSet) Equal ¶
func (c *CanonicalSet) Equal(other *CanonicalSet) bool
Equal returns true if the CanonicalSet equals the input CanonicalSet
func (*CanonicalSet) Intersect ¶
func (c *CanonicalSet) Intersect(other *CanonicalSet) *CanonicalSet
Intersect returns the intersection of the current set with the input set
func (*CanonicalSet) Intervals ¶
func (c *CanonicalSet) Intervals() []Interval
func (*CanonicalSet) IsEmpty ¶
func (c *CanonicalSet) IsEmpty() bool
IsEmpty returns true if the CanonicalSet is empty
func (*CanonicalSet) IsSingleNumber ¶
func (c *CanonicalSet) IsSingleNumber() bool
func (*CanonicalSet) Min ¶
func (c *CanonicalSet) Min() int64
func (*CanonicalSet) NumIntervals ¶
func (c *CanonicalSet) NumIntervals() int
func (*CanonicalSet) Overlap ¶
func (c *CanonicalSet) Overlap(other *CanonicalSet) bool
Overlap returns true if current CanonicalSet overlaps with input CanonicalSet
func (*CanonicalSet) String ¶
func (c *CanonicalSet) String() string
String returns a string representation of the current CanonicalSet object
func (*CanonicalSet) Subtract ¶
func (c *CanonicalSet) Subtract(other *CanonicalSet) *CanonicalSet
Subtract returns the subtraction result of input CanonicalSet
func (*CanonicalSet) Union ¶
func (c *CanonicalSet) Union(other *CanonicalSet) *CanonicalSet
Union returns the union of the two sets
type Interval ¶
type Interval struct {
// contains filtered or unexported fields
}
Interval is an integer interval from start to end inclusive
func (Interval) IsEmpty ¶ added in v0.3.1
IsEmpty returns true if the interval is empty, false otherwise. An interval is considered empty if its start is greater than its end.
func (Interval) ShortString ¶ added in v0.3.1
ShortString returns a compacted String representation of Interval object: "v" instead of "v-v", without braces
func (Interval) ToSet ¶
func (i Interval) ToSet() *CanonicalSet