mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-30 09:43:17 -04:00 
			
		
		
		
	* plugin/file: Rename do to walk, cleanup and document * This renames Do to Walk to be more inline with Go standards. Also make it return an error instead of a bool. Also give give walk access to rrs. Alternatively e.m could be exported, but just access the map of rrs should work as well. Another alternative would be adding a whole bunch of helper functions, but those need grab and return the data. Just having access to the rrs should be easiest for most Walks. * It adds Type and TypeForWildcard to show the different functions * *Removes* the identical RR check when inserting; this was only done for A, AAAA and MX and not finished; removed under the mantra garbage in garbage out. * Reuses Types to return all the types in an *tree.Elem Signed-off-by: Miek Gieben <miek@miek.nl> * better comments Signed-off-by: Miek Gieben <miek@miek.nl>
		
			
				
	
	
		
			22 lines
		
	
	
		
			367 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			367 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package tree
 | |
| 
 | |
| // All traverses tree and returns all elements.
 | |
| func (t *Tree) All() []*Elem {
 | |
| 	if t.Root == nil {
 | |
| 		return nil
 | |
| 	}
 | |
| 	found := t.Root.all(nil)
 | |
| 	return found
 | |
| }
 | |
| 
 | |
| func (n *Node) all(found []*Elem) []*Elem {
 | |
| 	if n.Left != nil {
 | |
| 		found = n.Left.all(found)
 | |
| 	}
 | |
| 	found = append(found, n.Elem)
 | |
| 	if n.Right != nil {
 | |
| 		found = n.Right.all(found)
 | |
| 	}
 | |
| 	return found
 | |
| }
 |