mirror of https://github.com/rwxrob/bonzai
Reconsolidate filter subpackage
parent
a3a454350a
commit
2c74b4dd18
@ -1,26 +0,0 @@
|
||||
// Copyright 2022 Robert S. Muhlestein.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package filter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// Println prints ever element of the set.
|
||||
func Println[T P](set []T) {
|
||||
for _, i := range set {
|
||||
fmt.Println(i)
|
||||
}
|
||||
}
|
||||
|
||||
// Keys returns the keys in lexicographically sorted order.
|
||||
func Keys[T any](m map[string]T) []string {
|
||||
keys := []string{}
|
||||
for k, _ := range m {
|
||||
keys = append(keys, k)
|
||||
sort.Strings(keys)
|
||||
}
|
||||
return keys
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
// Copyright 2022 Robert S. Muhlestein.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package filter_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/rwxrob/bonzai/filter"
|
||||
)
|
||||
|
||||
func ExamplePrintln() {
|
||||
set := []string{"doe", "ray", "mi"}
|
||||
filter.Println(set)
|
||||
bools := []bool{false, true, true}
|
||||
filter.Println(bools)
|
||||
// Output:
|
||||
// doe
|
||||
// ray
|
||||
// mi
|
||||
// false
|
||||
// true
|
||||
// true
|
||||
}
|
||||
|
||||
func ExampleKeys() {
|
||||
m1 := map[string]int{"two": 2, "three": 3, "one": 1}
|
||||
m2 := map[string]string{"two": "two", "three": "three", "one": "one"}
|
||||
fmt.Println(filter.Keys(m1))
|
||||
fmt.Println(filter.Keys(m2))
|
||||
// Output:
|
||||
// [one three two]
|
||||
// [one three two]
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
// Copyright 2022 Robert S. Muhlestein.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package filter
|
||||
|
||||
// Number combines the primitives generally considered numbers by JSON
|
||||
// and other high-level structure data representations.
|
||||
type Number interface {
|
||||
int16 | int32 | int64 | float32 | float64
|
||||
}
|
||||
|
||||
// Text combines byte slice and string.
|
||||
type Text interface {
|
||||
[]byte | string
|
||||
}
|
||||
|
||||
// P is for "principle" in this case. These are the types that have
|
||||
// representations in JSON and other high-level structured data
|
||||
// representations.
|
||||
type P interface {
|
||||
int16 | int32 | int64 | float32 | float64 |
|
||||
[]byte | string | bool
|
||||
}
|
Loading…
Reference in New Issue