Documentation
¶
Overview ¶
generator provides low level structures and functions used to efficiently generate strings from a regex pattern
Example (IncSplitConcat) ¶
// this is not an actual example, but an internal test. lls := [][]int{ {0, 0, 4}, {0, 3}, {2}, {}, {0, 0, 0, 1}, } for _, ll := range lls { n := sum(ll) var err error fmt.Println() fmt.Println(ll) // initial value for err == nil { err = incSplitConcat(ll) if n != sum(ll) { panic("incSplitConcat changed the sum of the split") } fmt.Println(ll, err) } }
Output: [0 0 4] [1 0 3] <nil> [2 0 2] <nil> [3 0 1] <nil> [4 0 0] <nil> [0 1 3] <nil> [1 1 2] <nil> [2 1 1] <nil> [3 1 0] <nil> [0 2 2] <nil> [1 2 1] <nil> [2 2 0] <nil> [0 3 1] <nil> [1 3 0] <nil> [0 4 0] <nil> [0 0 4] done [0 3] [1 2] <nil> [2 1] <nil> [3 0] <nil> [0 3] done [2] [2] done [] [] done [0 0 0 1] [1 0 0 0] <nil> [0 1 0 0] <nil> [0 0 1 0] <nil> [0 0 0 1] done
Example (IncSplitStar) ¶
// this is not an actual example, but an internal test. ss := [][]int{ {4}, {}, {1}, } for _, s := range ss { var err error fmt.Println("\nStarting with ", s) for err == nil { s, err = incSplitStar(s) fmt.Println(s, err) } }
Output: Starting with [4] [3 1] <nil> [2 2] <nil> [2 1 1] <nil> [1 3] <nil> [1 2 1] <nil> [1 1 2] <nil> [1 1 1 1] <nil> [] done Starting with [] [] done Starting with [1] [] done
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrDone = fmt.Errorf("done")
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator interface { // Sould be called before next is called. // Error only on irrecoverable errors. // Never error if nothing can be generated. Reset(length int) error // Generate next string // Returns error if no more string available. Next() error // Retrieve the last generated string. // May be called multiple times, and will always // return the same result until Next() is called again. // Undefined if called before Next() is called. Last() string }
func NewGenerator ¶
Compile a pattern into a new Generator. You must provide a maximum length (ie, capacity) for further resets. The new generator has to be reset to the target length(less or equal to max) before Next() can be called and Last() can be read.
Click to show internal directories.
Click to hide internal directories.