Exemplo n.º 1
0
// CheckAndUpdate checks if a predicate should be considered and it also updates
// the internal state in case counts are needed.
func (c *checker) CheckAndUpdate(p *predicate.Predicate) bool {
	if c.max {
		if c.c <= 0 {
			return false
		}
		c.c--
	}
	if p.Type() == predicate.Immutable {
		return true
	}
	t, _ := p.TimeAnchor()
	if c.o.LowerAnchor != nil && t.Before(*c.o.LowerAnchor) {
		return false
	}
	if c.o.UpperAnchor != nil && t.After(*c.o.UpperAnchor) {
		return false
	}
	return true
}
Exemplo n.º 2
0
// CheckAndUpdate checks if a predicate should be considered and it also updates
// the internal state in case counts are needed.
func (c *checker) CheckAndUpdate(p *predicate.Predicate) bool {
	if c.max {
		if c.c <= 0 {
			return false
		}
		// TODO: Should it be decremented if later function returns false?
		c.c--
	}
	if p.Type() == predicate.Immutable {
		return true
	}
	t, _ := p.TimeAnchor()
	if c.o.LowerAnchor != nil && t.Before(*c.o.LowerAnchor) {
		return false
	}
	if c.o.UpperAnchor != nil && t.After(*c.o.UpperAnchor) {
		return false
	}
	return true
}