diff --git a/examples/collisions.go b/examples/collisions.go new file mode 100644 index 0000000..61d8e1e --- /dev/null +++ b/examples/collisions.go @@ -0,0 +1,36 @@ +package main + +import ( + "log" + + "git.staur.ca/stobbsm/tind" +) + +var ( + longRuneSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+-=[]{}/';:.>,<`~" + shortRuneSet = "0123456789" +) + +func CollisionChecks() { + log.Println("Using multiple configurations, test for collisions multiple times") + + for i := 0; i < 10; i++ { + log.Printf("Check %d", i) + log.Printf("Using default values, collision after %d iterations", runCheck(tind.Gen().Config())) + } + + +} + +func runCheck(tconfig *tind.Config) uint64 { + var i uint64 + tmap := make(map[string]struct{}) + for { + i++ + t := tconfig.Gen() + if _, ok := tmap[t.String()]; ok { + return i + } + tmap[t.String()] = struct{}{} + } +} diff --git a/examples/default.go b/examples/default.go new file mode 100644 index 0000000..0053320 --- /dev/null +++ b/examples/default.go @@ -0,0 +1,16 @@ +package main + +import ( + "fmt" + + "git.staur.ca/stobbsm/tind" +) + +func GenWithDefaults() { + fmt.Println("Generate 16 different TinD ID's, and print them in both string and byte representations using the default config") + + for i := 0; i < 16; i++ { + t := tind.Gen() + fmt.Printf("String: `%s` Bytes: %v\n", t.String(), t.Bytes()) + } +} diff --git a/examples/emojirunes.go b/examples/emojirunes.go new file mode 100644 index 0000000..e69de29 diff --git a/examples/reallylong.go b/examples/reallylong.go new file mode 100644 index 0000000..e69de29