From 02265fd5abf2bc227f382dcbd78e295654bda697 Mon Sep 17 00:00:00 2001 From: bloeys Date: Sat, 11 Jun 2022 04:31:56 +0400 Subject: [PATCH] Improve docs --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 62bd11d..811bd65 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ To install run `go get github.com/bloeys/nset` Then usage is very simple: ```go +//Basic mySet := nset.NewNSet[uint32]() mySet.Add(0) @@ -74,6 +75,22 @@ if mySet.Contains(5) { mySet.Remove(4) +// Intersections +myOtherSet := nset.NewNSet[uint32]() +myOtherSet.AddMany(0, 1, 2, 4, 14) + +println("There is intersection:", myOtherSet.HasIntersection(mySet)) //True + +intersection := mySet.GetIntersection(myOtherSet) +println("The intersection contains 300:", intersection.Contains(300)) //False +println("The intersection contains 0 and 4:", intersection.ContainsAll(0, 4)) //True + +//Unions +unionOfBothSets := nset.UnionSets(mySet, myOtherSet) +println(unionOfBothSets.ContainsAll(0, 1, 2, 4, 14, 256, 300)) //True + +myOtherSet.Union(mySet) //This will change 'myOtherSet' +println(myOtherSet.ContainsAll(0, 1, 2, 4, 14, 256, 300)) //True ``` ## Benchmarks