@Test public void testFromCollection() { List<String> strings = Arrays.asList("a", "b", "c", "d", "e", "f"); ListHead<String> head = ListHead.fromCollection(strings); assertNotNull(head); assertEquals(strings.size(), head.size()); assertEquals(strings, head.toList()); }
public static <T> ListHead<T> fromCollection(Collection<T> collection) { ListHead<T> head = new ListHead<T>(); ListItem<T> previous = null; for(T item : collection) { ListItem<T> member = new ListItem<T>(item); member.insertAfter(head, previous); previous = member; } return head; }
ListHead implements Iterable<T> { public static <T> ListHead<T> fromCollection(Collection<T> collection) { ListHead<T> head = new ListHead<T>(); ListItem<T> previous = null; for(T item : collection) { ListItem<T> member = new ListItem<T>(item); member.insertAfter(head, previous); previous = member; } return head; } }
ListHead implements Iterable<T> { public static <T> ListHead<T> fromCollection(Collection<T> collection) { ListHead<T> head = new ListHead<T>(); ListItem<T> previous = null; for(T item : collection) { ListItem<T> member = new ListItem<T>(item); member.insertAfter(head, previous); previous = member; } return head; } private  ListHead(); private  ListHead(ListHead<T> other); }
ListHead implements Iterable<T> { public static <T> ListHead<T> fromCollection(Collection<T> collection) { ListHead<T> head = new ListHead<T>(); ListItem<T> previous = null; for(T item : collection) { ListItem<T> member = new ListItem<T>(item); member.insertAfter(head, previous); previous = member; } return head; } private  ListHead(); private  ListHead(ListHead<T> other); static ListHead<T> newInstance(); static ListHead<T> newInstance(ListHead<T> other); boolean isEmpty(); void clear(); T getFirstItem(); int size(); ListItem<T> find(Object value); boolean contains(Object value); ListItem<T> push(T value); T pop(); List<T> toList(); static ListHead<T> fromCollection(Collection<T> collection); @Override Iterator<T> iterator(); @Override String toString(); }
ListHead implements Iterable<T> { public static <T> ListHead<T> fromCollection(Collection<T> collection) { ListHead<T> head = new ListHead<T>(); ListItem<T> previous = null; for(T item : collection) { ListItem<T> member = new ListItem<T>(item); member.insertAfter(head, previous); previous = member; } return head; } private  ListHead(); private  ListHead(ListHead<T> other); static ListHead<T> newInstance(); static ListHead<T> newInstance(ListHead<T> other); boolean isEmpty(); void clear(); T getFirstItem(); int size(); ListItem<T> find(Object value); boolean contains(Object value); ListItem<T> push(T value); T pop(); List<T> toList(); static ListHead<T> fromCollection(Collection<T> collection); @Override Iterator<T> iterator(); @Override String toString(); public ListItem<T> first; }