func (t *Tree) Add(owner string, data interface{}, updater func(interface{}) interface{}) {
	nv := namev(owner)
	n := len(nv)
	this := t.root
	for i, label := range nv {
		switch node := this.(type) {
		case indexnode:
			if next, ok := node[label]; ok {
				if i+1 == n {
					switch x := next.(type) {
					case indexnode:
						node[label] = mixednode{x, data}
					case mixednode:
						if updater == nil {
							x.data = data // overwrite
						} else {
							x.data = updater(x.data) // update
						}
						node[label] = x
					default: // data node
						if updater == nil {
							node[label] = data // overwrite
						} else {
							node[label] = updater(x) // update
						}
					}
				} else {
					switch x := next.(type) {
					case indexnode:
						this = x
					case mixednode:
						this = x.indexnode
					default: // data node
						next = mixednode{map[string]interface{}{}, x}
						node[label] = next
						this = next
					}
				}
			} else {
				if i+1 == n {
					node[label] = data
				} else {
					next = indexnode(map[string]interface{}{})
					node[label] = next
					this = next
				}
			}
		case mixednode:
			//if _, ok := node.indexnode[label]; ok {
			//panic("dns.Tree.Put() internal error 2")
			//} else {
			if i+1 == n {
				node.indexnode[label] = data
			} else {
				next := indexnode(map[string]interface{}{})
				node.indexnode[label] = next
				this = next
			}
			//}
		default:
			panic("dns.Tree.Add() internal error")
		}
	}
}
// Add will add data to Tree. If the owner node has no data yet, the data will
// be simply inserted in that node. If the updater is not nil and the owner
// node already has some existing data then the value returned by
// updater(existing_data) is inserted into the owner node.
Add will add data to Tree. If the owner node has no data yet, the data will
be simply inserted in that node. If the updater is not nil and the owner
node already has some existing data then the value returned by
updater(existing_data) is inserted into the owner node.
// Add will add data to Tree . If the owner node has no data yet the data will // be simply inserted in that node . If the updater is not nil and the owner // node already has some existing data then the value returned by // updater ( existing_data ) is inserted into the owner node .
func (t *Tree) Add(owner string, data interface{}, updater func(interface{}) interface{}) {
	nv := namev(owner)
	n := len(nv)
	this := t.root
	for i, label := range nv {
		switch node := this.(type) {
		case indexnode:
			if next, ok := node[label]; ok {
				if i+1 == n {
					switch x := next.(type) {
					case indexnode:
						node[label] = mixednode{x, data}
					case mixednode:
						if updater == nil {
							x.data = data 
						} else {
							x.data = updater(x.data) 
						}
						node[label] = x
					default: 
						if updater == nil {
							node[label] = data 
						} else {
							node[label] = updater(x) 
						}
					}
				} else {
					switch x := next.(type) {
					case indexnode:
						this = x
					case mixednode:
						this = x.indexnode
					default: 
						next = mixednode{map[string]interface{}{}, x}
						node[label] = next
						this = next
					}
				}
			} else {
				if i+1 == n {
					node[label] = data
				} else {
					next = indexnode(map[string]interface{}{})
					node[label] = next
					this = next
				}
			}
		case mixednode:
			if i+1 == n {
				node.indexnode[label] = data
			} else {
				next := indexnode(map[string]interface{}{})
				node.indexnode[label] = next
				this = next
			}
		default:
			panic("dns.Tree.Add() internal error")
		}
	}
}
func ( t * Tree ) Add ( owner string , data interface { } , updater func ( interface { } ) interface { } ) { nv := namev ( owner ) n := len ( nv ) this := t . root for i , label := range nv { switch node := this . ( type ) { case indexnode : if next , ok := node [ label ] ; ok { if i + 1 == n { switch x := next . ( type ) { case indexnode : node [ label ] = mixednode { x , data } case mixednode : if updater == nil { x . data = data } else { x . data = updater ( x . data ) } node [ label ] = x default : if updater == nil { node [ label ] = data } else { node [ label ] = updater ( x ) } } } else { switch x := next . ( type ) { case indexnode : this = x case mixednode : this = x . indexnode default : next = mixednode { map [ string ] interface { } { } , x } node [ label ] = next this = next } } } else { if i + 1 == n { node [ label ] = data } else { next = indexnode ( map [ string ] interface { } { } ) node [ label ] = next this = next } } case mixednode : if i + 1 == n { node . indexnode [ label ] = data } else { next := indexnode ( map [ string ] interface { } { } ) node . indexnode [ label ] = next this = next } default : panic ( " " ) } } }
Add will add data to Tree.
Add will add data to Tree .
// overwrite // update // data node // overwrite // update // data node //if _, ok := node.indexnode[label]; ok { //panic("dns.Tree.Put() internal error 2") //} else { //}