Documentation
¶
Index ¶
- Constants
- Variables
- type Setsum
- func (s *Setsum) Add(other *Setsum)
- func (s *Setsum) Digest() [SetsumBytes]byte
- func (s *Setsum) HexDigest() string
- func (s *Setsum) Insert(item []byte)
- func (s *Setsum) InsertMany(items [][]byte)
- func (s *Setsum) Remove(item []byte)
- func (s *Setsum) RemoveMany(items [][]byte)
- func (s *Setsum) Subtract(other *Setsum)
Examples ¶
Constants ¶
View Source
const SetsumBytes = 32
View Source
const SetsumBytesPerColumn = 4
View Source
const SetsumColumns = SetsumBytes / SetsumBytesPerColumn
Variables ¶
View Source
var SetsumPrimes = [...]uint32{
4294967291, 4294967279, 4294967231, 4294967197, 4294967189, 4294967161, 4294967143, 4294967111}
Functions ¶
This section is empty.
Types ¶
type Setsum ¶
type Setsum struct {
// contains filtered or unexported fields
}
Example ¶
s1 := NewSetsum()
// add some items
s1.Insert([]byte("hello"))
s1.Insert([]byte("world"))
// add same items but in different order
s2 := NewSetsum()
s2.Insert([]byte("world"))
s2.Insert([]byte("hello"))
fmt.Printf("Digests equal: %t\n", s1.Digest() == s2.Digest())
Output: Digests equal: true
func (*Setsum) Digest ¶
func (s *Setsum) Digest() [SetsumBytes]byte
func (*Setsum) Insert ¶
Example ¶
s := NewSetsum()
s.Insert([]byte("hello"))
s.Insert([]byte("hello"))
// remove the dupe
s.Remove([]byte("hello"))
c := NewSetsum()
c.Insert([]byte("hello"))
fmt.Printf("`hello hello` after removing one 'hello' equals digest of 'hello': %t\n", s.Digest() == c.Digest())
Output: `hello hello` after removing one 'hello' equals digest of 'hello': true
func (*Setsum) InsertMany ¶
func (*Setsum) Remove ¶
Example ¶
s := NewSetsum()
s.Insert([]byte("hello"))
s.Insert([]byte("world"))
// remove in different order
s.Remove([]byte("hello"))
{
world := NewSetsum()
world.Insert([]byte("world"))
fmt.Printf("`hello world` after removing 'hello' equals digest of 'world': %t\n", s.Digest() == world.Digest())
}
s.Remove([]byte("world"))
empty := NewSetsum()
fmt.Printf("Digest after removing all items equals empty digest: %t\n", s.Digest() == empty.Digest())
Output: `hello world` after removing 'hello' equals digest of 'world': true Digest after removing all items equals empty digest: true
func (*Setsum) RemoveMany ¶
Click to show internal directories.
Click to hide internal directories.