src/share/classes/com/sun/tools/javac/util/List.java

changeset 2000
4a6acc42c3a1
parent 1759
05ec778794d0
child 2047
5f915a0c9615
equal deleted inserted replaced
1999:7993cfab8610 2000:4a6acc42c3a1
114 } 114 }
115 } 115 }
116 return buf.toList(); 116 return buf.toList();
117 } 117 }
118 118
119 /**
120 * Create a new list from the first {@code n} elements of this list
121 */
122 public List<A> take(int n) {
123 ListBuffer<A> buf = ListBuffer.lb();
124 int count = 0;
125 for (A el : this) {
126 if (count++ == n) break;
127 buf.append(el);
128 }
129 return buf.toList();
130 }
131
119 /** Construct a list consisting of given element. 132 /** Construct a list consisting of given element.
120 */ 133 */
121 public static <A> List<A> of(A x1) { 134 public static <A> List<A> of(A x1) {
122 return new List<A>(x1, List.<A>nil()); 135 return new List<A>(x1, List.<A>nil());
123 } 136 }

mercurial