1 package net.sf.jga.util; 33 34 import java.util.Collection ; 35 import java.util.Iterator ; 36 37 45 46 public class CollectionUtils { 47 54 static public <T> boolean addAll(Collection <? super T> cout, Iterator <T> iter) { 55 boolean b = false; 56 while(iter.hasNext()) { 57 b |= cout.add(iter.next()); 58 } 59 60 return b; 61 } 62 63 64 71 static public <T> boolean addAll(Collection <? super T> cout, T... values) { 72 boolean b = false; 73 for(int i = 0; i < values.length; ++i) { 74 b |= cout.add(values[i]); 75 } 76 77 return b; 78 } 79 80 85 static public <T,TCollection extends Collection <? super T>> TCollection 86 append(TCollection cout, Iterable <T> iterable) 87 { 88 addAll(cout, iterable.iterator()); 89 return cout; 90 } 91 92 93 98 static public <T,TCollection extends Collection <? super T>> TCollection 99 append(TCollection cout, Iterator <T> iter) 100 { 101 addAll(cout, iter); 102 return cout; 103 } 104 105 106 112 static public <T,TCollection extends Collection <? super T>> TCollection 113 append(TCollection cout, T... values) 114 { 115 addAll(cout, values); 116 return cout; 117 } 118 } 119 | Popular Tags |