Skip to content

Commit

Permalink
use review suggestions for Left, Right, Swap
Browse files Browse the repository at this point in the history
Signed-off-by: Elazar Gershuni <[email protected]>
  • Loading branch information
elazarg committed Aug 14, 2024
1 parent e84b32f commit 03d358c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 4 additions & 3 deletions pkg/ds/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,19 @@ type Product[S1 Set[S1], S2 Set[S2]] interface {
// Partitions returns a slice of pairs such that, for (p Product):
// p.Equal(Union(CartesianPairLeft(s1, s2) for _, (s1, s2) := range p.Partitions())
// (note that the order is arbitrary; we do not return HashSet because Pair is not Hashable)
// Partitions returns a slice of pairs in the product set (note that the order is arbitrary)
Partitions() []Pair[S1, S2]

// NumPartitions returns len(Partitions()). It is different from Size() which should return the number of concrete pairs of elements.
NumPartitions() int

// Left returns the projection of Product[S1, S2] on the set S1. If the product is empty, it returns the empty set.
// Left returns the left projection from pairs in the product set on S1, given input of an empty set in S1.
Left(empty S1) S1

// Right returns the projection of Product[S1, S2] on the set S2. If the product is empty, it returns the empty set.
// Right returns the right projection from pairs in the product set S2, given input of an empty set in S2.
Right(empty S2) S2

// Swap returns a new Product object, built from the receiver object, with left and right swapped
// Swap returns a new Product object, built from the input object, with left and right swapped.
Swap() Product[S2, S1]
}

Expand Down
10 changes: 8 additions & 2 deletions pkg/netset/connectionset_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package netset_test

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/np-guard/models/pkg/connection"
"github.com/np-guard/models/pkg/netset"
"github.com/stretchr/testify/require"
)

func TestConnectionSetBasicOperations(t *testing.T) {
Expand Down Expand Up @@ -36,5 +43,4 @@ func TestConnectionSetBasicOperations(t *testing.T) {
// basic IsEmpty test
require.False(t, conn1.IsEmpty())
require.True(t, netset.NewConnectionSet().IsEmpty())

}

0 comments on commit 03d358c

Please sign in to comment.