added comments

This commit is contained in:
ston1th 2017-07-09 15:17:59 +02:00
commit da12fce77a

View file

@ -12,6 +12,12 @@ import (
const any = '*'
// Filter is the filter interface to be implemented for faster non generic filtering
// Example implementation:
// type f []struct
// func (v f) Len() int { return len(v) }
// func (v f) Index(i int) interface{} { return v[i] }
// func (v *f) Remove(i, j int) { *v = append((*v)[:i], (*v)[j:]...) }
type Filter interface {
Len() int
Index(int) interface{}
@ -23,15 +29,19 @@ type match struct {
value string
}
// Logic is the filter logic
type Logic int
const (
// AND all of the queries have to match
AND Logic = iota
// OR only one query has to match
OR
// NOT none of the queries have to match
NOT
)
// Query implements the filter query
// Query is the filter query
type Query struct {
m []match
l Logic
@ -260,6 +270,8 @@ func (q *Query) GenericFilter(i interface{}) interface{} {
return ret.Interface()
}
// Filter takes a pointer to the Filter interface as an argument.
// The original slice is modified is the filtering process.
func (q Query) Filter(f Filter) {
count := 0
i := 0