@Override @SuppressWarnings("unchecked") public boolean contains(Object o) { if(o==null) return false; // TODO: How can we check if the passed-in object is of an unrelated, unexpected class // TODO: without passing around Class objects? // TODO: with equals - just like ArraySet. return binarySearch((E)o) >= 0; }
@Override public boolean isMatch(String paramName) { for(WildcardPatternMatcher matcher : matchers) { if(matcher.isMatch(paramName)) return true; } return false; } };
/** * Returns <tt>true</tt> if this list contains the specified element. * * @param elem element whose presence in this List is to be tested. * @return <code>true</code> if the specified element is present; * <code>false</code> otherwise. */ @Override public boolean contains(long elem) { return indexOf(elem) >= 0; }
/** * Loads properties from the classpath. */ public PropertiesVersions(Class<?> clazz, String resource) throws IOException { this(PropertiesUtils.loadFromResource(clazz, resource)); }
/** * Finds the first index of an element or <code>-1</code> if not found. */ public static <E> int indexOf(E[] array, E element) { return indexOf(array, element, 0); }
/** * Finds the last index of an element or <code>-1</code> if not found. */ public static int lastIndexOf(short[] array, short element) { return lastIndexOf(array, element, array.length-1); }
@Override public boolean containsAll(Collection<?> c) { // Could do a nifty single-pass merge if the other collection is also an UnmodifiableArraySet and contains a large number of elements for(Object o : c) if(!contains(o)) return false; return true; }
@Override public boolean hasNext() { prepareNextValue(); return nextElement!=null; }
/** * Uses the provided elements, which must already be sorted in hashCode order and unique. * * The sort order and uniqueness is only checked with assertions enabled. * * @see HashCodeComparator to properly sort objects before adding to the set */ public UnmodifiableArraySet(E... elements) { if(ASSERTIONS_ENABLED) assert inOrderAndUnique(elements); this.elements = elements; }
/** * @see java.util.Stack#push */ public E push(E item) { add(item); return item; }
/** * Finds the first occurrence of any of the supplied characters * * @param S the <code>String</code> to search * @param chars the characters to look for * * @return the index of the first occurrence of <code>-1</code> if none found */ public static int indexOf(String S, char[] chars) { return indexOf(S, chars, 0); }
/** * Returns <tt>true</tt> if this list contains the specified element. * * @param elem element whose presence in this List is to be tested. * @return <code>true</code> if the specified element is present; * <code>false</code> otherwise. */ @Override public boolean contains(int elem) { return indexOf(elem) >= 0; }
/** * Gets an unmodifiable iterator for a single object. */ public static <E> Iterator<E> singletonIterator(E value) { return new SingletonIterator<E>(value); }
/** * Finds the first index of an element or <code>-1</code> if not found. */ public static int indexOf(char[] array, char element) { return indexOf(array, element, 0); }
/** * Finds the last index of an element or <code>-1</code> if not found. */ public static <E> int lastIndexOf(E[] array, E element) { return lastIndexOf(array, element, array.length-1); }
/** * Finds the first index of an element or <code>-1</code> if not found. */ public static int indexOf(short[] array, short element) { return indexOf(array, element, 0); }
/** * Finds the last index of an element or <code>-1</code> if not found. */ public static int lastIndexOf(float[] array, float element) { return lastIndexOf(array, element, array.length-1); }
/** * Finds the first index of an element or <code>-1</code> if not found. */ public static int indexOf(float[] array, float element) { return indexOf(array, element, 0); }
/** * Finds the first index of an element or <code>-1</code> if not found. */ public static int indexOf(int[] array, int element) { return indexOf(array, element, 0); }
/** * Finds the first index of an element or <code>-1</code> if not found. */ public static int indexOf(double[] array, double element) { return indexOf(array, element, 0); }