1 17 package org.apache.commons.collections.primitives; 18 19 import org.apache.commons.collections.primitives.decorators.UnmodifiableLongIterator; 20 import org.apache.commons.collections.primitives.decorators.UnmodifiableLongList; 21 import org.apache.commons.collections.primitives.decorators.UnmodifiableLongListIterator; 22 23 34 public final class LongCollections { 35 36 41 public static LongList singletonLongList(long value) { 42 LongList list = new ArrayLongList(1); 44 list.add(value); 45 return UnmodifiableLongList.wrap(list); 46 } 47 48 53 public static LongIterator singletonLongIterator(long value) { 54 return singletonLongList(value).iterator(); 55 } 56 57 62 public static LongListIterator singletonLongListIterator(long value) { 63 return singletonLongList(value).listIterator(); 64 } 65 66 73 public static LongList unmodifiableLongList(LongList list) throws NullPointerException { 74 if(null == list) { 75 throw new NullPointerException (); 76 } 77 return UnmodifiableLongList.wrap(list); 78 } 79 80 87 public static LongIterator unmodifiableLongIterator(LongIterator iter) { 88 if(null == iter) { 89 throw new NullPointerException (); 90 } 91 return UnmodifiableLongIterator.wrap(iter); 92 } 93 94 101 public static LongListIterator unmodifiableLongListIterator(LongListIterator iter) { 102 if(null == iter) { 103 throw new NullPointerException (); 104 } 105 return UnmodifiableLongListIterator.wrap(iter); 106 } 107 108 113 public static LongList getEmptyLongList() { 114 return EMPTY_LONG_LIST; 115 } 116 117 122 public static LongIterator getEmptyLongIterator() { 123 return EMPTY_LONG_ITERATOR; 124 } 125 126 131 public static LongListIterator getEmptyLongListIterator() { 132 return EMPTY_LONG_LIST_ITERATOR; 133 } 134 135 139 public static final LongList EMPTY_LONG_LIST = unmodifiableLongList(new ArrayLongList(0)); 140 141 145 public static final LongIterator EMPTY_LONG_ITERATOR = unmodifiableLongIterator(EMPTY_LONG_LIST.iterator()); 146 147 151 public static final LongListIterator EMPTY_LONG_LIST_ITERATOR = unmodifiableLongListIterator(EMPTY_LONG_LIST.listIterator()); 152 } 153 | Popular Tags |