interval

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

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

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 New

func New(start, end int64) Interval

func (Interval) Elements added in v0.3.1

func (i Interval) Elements() []int64

func (Interval) End

func (i Interval) End() int64

func (Interval) Equal

func (i Interval) Equal(x Interval) bool

Equal returns true if current Interval obj is equal to the input Interval

func (Interval) IsEmpty added in v0.3.1

func (i Interval) IsEmpty() bool

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

func (i Interval) ShortString() string

ShortString returns a compacted String representation of Interval object: "v" instead of "v-v", without braces

func (Interval) Size added in v0.3.0

func (i Interval) Size() int64

func (Interval) Start

func (i Interval) Start() int64

func (Interval) String

func (i Interval) String() string

String returns a String representation of Interval object

func (Interval) ToSet

func (i Interval) ToSet() *CanonicalSet

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL