Use a pointer where trees might get modified but a value has to be returned
This commit is contained in:
		
							parent
							
								
									39f3c2e2a2
								
							
						
					
					
						commit
						63377702ad
					
				
					 2 changed files with 16 additions and 4 deletions
				
			
		
							
								
								
									
										10
									
								
								src/aud/exam/prep/Pointer.java
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/aud/exam/prep/Pointer.java
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,10 @@ | |||
| package aud.exam.prep; | ||||
| 
 | ||||
| public class Pointer<T> { | ||||
| 
 | ||||
|     public T deref; | ||||
| 
 | ||||
|     public Pointer(T initial) { | ||||
|         deref = initial; | ||||
|     } | ||||
| } | ||||
|  | @ -1,5 +1,7 @@ | |||
| package aud.exam.prep.tree; | ||||
| 
 | ||||
| import aud.exam.prep.Pointer; | ||||
| 
 | ||||
| import java.util.Comparator; | ||||
| 
 | ||||
| /** | ||||
|  | @ -15,15 +17,15 @@ public interface OrderedTreeProcessor<V, T> { | |||
| 
 | ||||
|     boolean find(T t, V v, Comparator<V> cmp); | ||||
| 
 | ||||
|     boolean override(T t, V from, V to, Comparator<V> cmp); | ||||
|     boolean override(Pointer<T> t, V from, V to, Comparator<V> cmp); | ||||
| 
 | ||||
|     boolean overrideAll(T t, V from, V to, Comparator<V> cmp); | ||||
|     boolean overrideAll(Pointer<T> t, V from, V to, Comparator<V> cmp); | ||||
| 
 | ||||
|     T insert(T t, V v, Comparator<V> cmp); | ||||
| 
 | ||||
|     boolean remove(T t, V v, Comparator<V> cmp); | ||||
|     boolean remove(Pointer<T> t, V v, Comparator<V> cmp); | ||||
| 
 | ||||
|     boolean removeAll(T t, V v, Comparator<V> cmp); | ||||
|     boolean removeAll(Pointer<T> t, V v, Comparator<V> cmp); | ||||
| 
 | ||||
|     V max(T t); | ||||
| 
 | ||||
|  |  | |||
		Reference in a new issue