Add FindFunc
This commit is contained in:
parent
d5e6aaba0b
commit
ad7103ecdc
13
zone.go
13
zone.go
|
@ -213,6 +213,19 @@ func (z *Zone) Find(s string) (*ZoneData, bool) {
|
|||
return zd.Value.(*ZoneData), e
|
||||
}
|
||||
|
||||
// FindFunc works like Find, but the function f is executed on
|
||||
// each node which has a non-nil Value during the tree traversel.
|
||||
// If f returns true, that node is returned.
|
||||
func (z *Zone) FindFunc(s string, f func(interface{}) bool) (*ZoneData, bool, bool) {
|
||||
z.mutex.RLock()
|
||||
defer z.mutex.RUnlock()
|
||||
zd, e, b := z.Radix.FindFunc(toRadixName(s), f)
|
||||
if zd == nil {
|
||||
return nil, false, false
|
||||
}
|
||||
return zd.Value.(*ZoneData), e, b
|
||||
}
|
||||
|
||||
// Up bla bla
|
||||
func (z *Zone) Up(s string) *ZoneData {
|
||||
z.mutex.RLock()
|
||||
|
|
Loading…
Reference in New Issue