Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export functions #89

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions pkg/ds/tripleset_left.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func CartesianLeftTriple[S1 Set[S1], S2 Set[S2], S3 Set[S3]](s1 S1, s2 S2, s3 S3
}

func (c *LeftTripleSet[S1, S2, S3]) Equal(other TripleSet[S1, S2, S3]) bool {
return c.m.Equal(asLeftTripleSet(other).m)
return c.m.Equal(AsLeftTripleSet(other).m)
}

func (c *LeftTripleSet[S1, S2, S3]) Copy() TripleSet[S1, S2, S3] {
Expand All @@ -41,7 +41,7 @@ func (c *LeftTripleSet[S1, S2, S3]) Size() int {
return c.m.Size()
}

func asLeftTripleSet[S1 Set[S1], S2 Set[S2], S3 Set[S3]](other TripleSet[S1, S2, S3]) *LeftTripleSet[S1, S2, S3] {
func AsLeftTripleSet[S1 Set[S1], S2 Set[S2], S3 Set[S3]](other TripleSet[S1, S2, S3]) *LeftTripleSet[S1, S2, S3] {
r, ok := other.(*LeftTripleSet[S1, S2, S3])
if ok {
return r
Expand All @@ -55,19 +55,19 @@ func asLeftTripleSet[S1 Set[S1], S2 Set[S2], S3 Set[S3]](other TripleSet[S1, S2,

// IsSubset returns true if c is subset of other
func (c *LeftTripleSet[S1, S2, S3]) IsSubset(other TripleSet[S1, S2, S3]) bool {
return c.m.IsSubset(asLeftTripleSet(other).m)
return c.m.IsSubset(AsLeftTripleSet(other).m)
}

func (c *LeftTripleSet[S1, S2, S3]) Union(other TripleSet[S1, S2, S3]) TripleSet[S1, S2, S3] {
return &LeftTripleSet[S1, S2, S3]{m: c.m.Union(asLeftTripleSet(other).m)}
return &LeftTripleSet[S1, S2, S3]{m: c.m.Union(AsLeftTripleSet(other).m)}
}

func (c *LeftTripleSet[S1, S2, S3]) Intersect(other TripleSet[S1, S2, S3]) TripleSet[S1, S2, S3] {
return &LeftTripleSet[S1, S2, S3]{m: c.m.Intersect(asLeftTripleSet(other).m)}
return &LeftTripleSet[S1, S2, S3]{m: c.m.Intersect(AsLeftTripleSet(other).m)}
}

func (c *LeftTripleSet[S1, S2, S3]) Subtract(other TripleSet[S1, S2, S3]) TripleSet[S1, S2, S3] {
return &LeftTripleSet[S1, S2, S3]{m: c.m.Subtract(asLeftTripleSet(other).m)}
return &LeftTripleSet[S1, S2, S3]{m: c.m.Subtract(AsLeftTripleSet(other).m)}
}

func (c *LeftTripleSet[S1, S2, S3]) NumPartitions() int {
Expand Down Expand Up @@ -96,7 +96,7 @@ func (c *LeftTripleSet[S1, S2, S3]) Partitions() []Triple[S1, S2, S3] {
func MapTripleSet[S1 Set[S1], S2 Set[S2], S3 Set[S3], T1 Set[T1], T2 Set[T2], T3 Set[T3]](c TripleSet[S1, S2, S3],
f func(Triple[S1, S2, S3]) Triple[T1, T2, T3]) TripleSet[T1, T2, T3] {
var res TripleSet[T1, T2, T3] = NewLeftTripleSet[T1, T2, T3]()
for _, triple := range partitionsMap(asLeftTripleSet(c), f) {
for _, triple := range partitionsMap(AsLeftTripleSet(c), f) {
res = res.Union(CartesianLeftTriple(triple.S1, triple.S2, triple.S3))
}
return res
Expand Down
12 changes: 6 additions & 6 deletions pkg/ds/tripleset_outer.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func CartesianOuterTriple[S1 Set[S1], S2 Set[S2], S3 Set[S3]](s1 S1, s2 S2, s3 S
}

func (c *OuterTripleSet[S1, S2, S3]) Equal(other TripleSet[S1, S2, S3]) bool {
return c.m.Equal(asOuterTripleSet(other).m)
return c.m.Equal(AsOuterTripleSet(other).m)
}

func (c *OuterTripleSet[S1, S2, S3]) Copy() TripleSet[S1, S2, S3] {
Expand All @@ -40,7 +40,7 @@ func (c *OuterTripleSet[S1, S2, S3]) Size() int {
return c.m.Size()
}

func asOuterTripleSet[S1 Set[S1], S2 Set[S2], S3 Set[S3]](other TripleSet[S1, S2, S3]) *OuterTripleSet[S1, S2, S3] {
func AsOuterTripleSet[S1 Set[S1], S2 Set[S2], S3 Set[S3]](other TripleSet[S1, S2, S3]) *OuterTripleSet[S1, S2, S3] {
r, ok := other.(*OuterTripleSet[S1, S2, S3])
if ok {
return r
Expand All @@ -54,19 +54,19 @@ func asOuterTripleSet[S1 Set[S1], S2 Set[S2], S3 Set[S3]](other TripleSet[S1, S2

// IsSubset returns true if c is subset of other
func (c *OuterTripleSet[S1, S2, S3]) IsSubset(other TripleSet[S1, S2, S3]) bool {
return c.m.IsSubset(asOuterTripleSet(other).m)
return c.m.IsSubset(AsOuterTripleSet(other).m)
}

func (c *OuterTripleSet[S1, S2, S3]) Union(other TripleSet[S1, S2, S3]) TripleSet[S1, S2, S3] {
return &OuterTripleSet[S1, S2, S3]{m: c.m.Union(asOuterTripleSet(other).m).(*LeftTripleSet[S1, S3, S2])}
return &OuterTripleSet[S1, S2, S3]{m: c.m.Union(AsOuterTripleSet(other).m).(*LeftTripleSet[S1, S3, S2])}
}

func (c *OuterTripleSet[S1, S2, S3]) Intersect(other TripleSet[S1, S2, S3]) TripleSet[S1, S2, S3] {
return &OuterTripleSet[S1, S2, S3]{m: c.m.Intersect(asOuterTripleSet(other).m).(*LeftTripleSet[S1, S3, S2])}
return &OuterTripleSet[S1, S2, S3]{m: c.m.Intersect(AsOuterTripleSet(other).m).(*LeftTripleSet[S1, S3, S2])}
}

func (c *OuterTripleSet[S1, S2, S3]) Subtract(other TripleSet[S1, S2, S3]) TripleSet[S1, S2, S3] {
return &OuterTripleSet[S1, S2, S3]{m: c.m.Subtract(asOuterTripleSet(other).m).(*LeftTripleSet[S1, S3, S2])}
return &OuterTripleSet[S1, S2, S3]{m: c.m.Subtract(AsOuterTripleSet(other).m).(*LeftTripleSet[S1, S3, S2])}
}

func (c *OuterTripleSet[S1, S2, S3]) Partitions() []Triple[S1, S2, S3] {
Expand Down
12 changes: 6 additions & 6 deletions pkg/ds/tripleset_right.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func CartesianRightTriple[S1 Set[S1], S2 Set[S2], S3 Set[S3]](s1 S1, s2 S2, s3 S
}

func (c *RightTripleSet[S1, S2, S3]) Equal(other TripleSet[S1, S2, S3]) bool {
return c.m.Equal(asRightTripleSet(other).m)
return c.m.Equal(AsRightTripleSet(other).m)
}

func (c *RightTripleSet[S1, S2, S3]) Copy() TripleSet[S1, S2, S3] {
Expand All @@ -40,7 +40,7 @@ func (c *RightTripleSet[S1, S2, S3]) Size() int {
return c.m.Size()
}

func asRightTripleSet[S1 Set[S1], S2 Set[S2], S3 Set[S3]](other TripleSet[S1, S2, S3]) *RightTripleSet[S1, S2, S3] {
func AsRightTripleSet[S1 Set[S1], S2 Set[S2], S3 Set[S3]](other TripleSet[S1, S2, S3]) *RightTripleSet[S1, S2, S3] {
r, ok := other.(*RightTripleSet[S1, S2, S3])
if ok {
return r
Expand All @@ -54,19 +54,19 @@ func asRightTripleSet[S1 Set[S1], S2 Set[S2], S3 Set[S3]](other TripleSet[S1, S2

// IsSubset returns true if c is subset of other
func (c *RightTripleSet[S1, S2, S3]) IsSubset(other TripleSet[S1, S2, S3]) bool {
return c.m.IsSubset(asRightTripleSet(other).m)
return c.m.IsSubset(AsRightTripleSet(other).m)
}

func (c *RightTripleSet[S1, S2, S3]) Union(other TripleSet[S1, S2, S3]) TripleSet[S1, S2, S3] {
return &RightTripleSet[S1, S2, S3]{m: c.m.Union(asRightTripleSet(other).m).(*LeftTripleSet[S2, S3, S1])}
return &RightTripleSet[S1, S2, S3]{m: c.m.Union(AsRightTripleSet(other).m).(*LeftTripleSet[S2, S3, S1])}
}

func (c *RightTripleSet[S1, S2, S3]) Intersect(other TripleSet[S1, S2, S3]) TripleSet[S1, S2, S3] {
return &RightTripleSet[S1, S2, S3]{m: c.m.Intersect(asRightTripleSet(other).m).(*LeftTripleSet[S2, S3, S1])}
return &RightTripleSet[S1, S2, S3]{m: c.m.Intersect(AsRightTripleSet(other).m).(*LeftTripleSet[S2, S3, S1])}
}

func (c *RightTripleSet[S1, S2, S3]) Subtract(other TripleSet[S1, S2, S3]) TripleSet[S1, S2, S3] {
return &RightTripleSet[S1, S2, S3]{m: c.m.Subtract(asRightTripleSet(other).m).(*LeftTripleSet[S2, S3, S1])}
return &RightTripleSet[S1, S2, S3]{m: c.m.Subtract(AsRightTripleSet(other).m).(*LeftTripleSet[S2, S3, S1])}
}

func (c *RightTripleSet[S1, S2, S3]) Partitions() []Triple[S1, S2, S3] {
Expand Down
Loading