1 17 package org.apache.commons.collections.primitives; 18 19 import org.apache.commons.collections.primitives.decorators.UnmodifiableIntIterator; 20 import org.apache.commons.collections.primitives.decorators.UnmodifiableIntList; 21 import org.apache.commons.collections.primitives.decorators.UnmodifiableIntListIterator; 22 23 34 public final class IntCollections { 35 36 41 public static IntList singletonIntList(int value) { 42 IntList list = new ArrayIntList(1); 44 list.add(value); 45 return UnmodifiableIntList.wrap(list); 46 } 47 48 53 public static IntIterator singletonIntIterator(int value) { 54 return singletonIntList(value).iterator(); 55 } 56 57 62 public static IntListIterator singletonIntListIterator(int value) { 63 return singletonIntList(value).listIterator(); 64 } 65 66 73 public static IntList unmodifiableIntList(IntList list) throws NullPointerException { 74 if(null == list) { 75 throw new NullPointerException (); 76 } 77 return UnmodifiableIntList.wrap(list); 78 } 79 80 87 public static IntIterator unmodifiableIntIterator(IntIterator iter) { 88 if(null == iter) { 89 throw new NullPointerException (); 90 } 91 return UnmodifiableIntIterator.wrap(iter); 92 } 93 94 101 public static IntListIterator unmodifiableIntListIterator(IntListIterator iter) { 102 if(null == iter) { 103 throw new NullPointerException (); 104 } 105 return UnmodifiableIntListIterator.wrap(iter); 106 } 107 108 113 public static IntList getEmptyIntList() { 114 return EMPTY_INT_LIST; 115 } 116 117 122 public static IntIterator getEmptyIntIterator() { 123 return EMPTY_INT_ITERATOR; 124 } 125 126 131 public static IntListIterator getEmptyIntListIterator() { 132 return EMPTY_INT_LIST_ITERATOR; 133 } 134 135 139 public static final IntList EMPTY_INT_LIST = unmodifiableIntList(new ArrayIntList(0)); 140 141 145 public static final IntIterator EMPTY_INT_ITERATOR = unmodifiableIntIterator(EMPTY_INT_LIST.iterator()); 146 147 151 public static final IntListIterator EMPTY_INT_LIST_ITERATOR = unmodifiableIntListIterator(EMPTY_INT_LIST.listIterator()); 152 } 153 | Popular Tags |