/** * Add unique element to the array. * @param <T> type of the array element * @param array array * @param element element to add * * @return array, which will contain the new element. Either new array instance, if * passed array didn't contain the element, or the same array instance, if the element * is already present in the array. */ public static <T> T[] addUnique(T[] array, T element) { return addUnique(array, element, true); }
/** * {@inheritDoc} */ @Override public boolean containsAll(Collection<?> collection) { if (collection.isEmpty()) { return true; } final Object[] localArray = array; for (Object element : collection) { if (ArrayUtils.indexOf(localArray, element) == -1) { return false; } } return true; }
/** * Remove element(s) from the set. * * @param elements the element(s) to remove. * @return <tt>true</tt>, if at least one element was found and removed, * or <tt>false</tt> otherwise. */ public final boolean removeAll(Object... elements) { if (elements.length == 0) { return false; } synchronized (sync) { if (array == null) { return false; } boolean result = false; for (Object element : elements) { final T[] oldArray = array; array = ArrayUtils.remove(array, element); result |= (oldArray != array); } return result; } }
private void recalcIndex(final int index) { final int idx = index < bufferBounds[0] ? 0 : ArrayUtils.binarySearch(bufferBounds, 0, buffersSize - 1, index + 1); activeBuffer = buffers[idx]; upperBound = bufferBounds[idx]; lowerBound = upperBound - activeBuffer.remaining(); lastSegmentIndex = idx; activeBufferLowerBound = lowerBound - activeBuffer.position(); }
private void recalcIndex(final int index) { final int idx = index < bufferBounds[0] ? 0 : ArrayUtils.binarySearch(bufferBounds, 0, buffersSize - 1, index + 1); activeBuffer = buffers[idx]; upperBound = bufferBounds[idx]; lowerBound = upperBound - activeBuffer.remaining(); lastSegmentIndex = idx; activeBufferLowerBound = lowerBound - activeBuffer.position(); }
/** * Add unique element to the array. * @param <T> type of the array element * @param array array * @param element element to add * * @return array, which will contain the new element. Either new array instance, if * passed array didn't contain the element, or the same array instance, if the element * is already present in the array. */ public static <T> T[] addUnique(T[] array, T element) { return addUnique(array, element, true); }
/** * {@inheritDoc} */ @Override public boolean containsAll(Collection<?> collection) { if (collection.isEmpty()) { return true; } final Object[] localArray = array; for (Object element : collection) { if (ArrayUtils.indexOf(localArray, element) == -1) { return false; } } return true; }
private void recalcIndex(final int index) { final int idx = index < bufferBounds[0] ? 0 : ArrayUtils.binarySearch(bufferBounds, 0, buffersSize - 1, index + 1); activeBuffer = buffers[idx]; upperBound = bufferBounds[idx]; lowerBound = upperBound - activeBuffer.remaining(); lastSegmentIndex = idx; activeBufferLowerBound = lowerBound - activeBuffer.position(); }
/** * Remove element(s) from the set. * * @param elements the element(s) to remove. * @return <tt>true</tt>, if at least one element was found and removed, * or <tt>false</tt> otherwise. */ public final boolean removeAll(Object... elements) { if (elements.length == 0) { return false; } synchronized (sync) { if (array == null) { return false; } boolean result = false; for (Object element : elements) { final T[] oldArray = array; array = ArrayUtils.remove(array, element); result |= (oldArray != array); } return result; } }
/** * Add unique element to the array. * @param <T> type of the array element * @param array array * @param element element to add * * @return array, which will contain the new element. Either new array instance, if * passed array didn't contain the element, or the same array instance, if the element * is already present in the array. */ public static <T> T[] addUnique(T[] array, T element) { return addUnique(array, element, true); }
/** * {@inheritDoc} */ @Override public boolean containsAll(Collection<?> collection) { if (collection.isEmpty()) { return true; } final Object[] localArray = array; for (Object element : collection) { if (ArrayUtils.indexOf(localArray, element) == -1) { return false; } } return true; }
private void recalcIndex(final int index) { final int idx = index < bufferBounds[0] ? 0 : ArrayUtils.binarySearch(bufferBounds, 0, buffersSize - 1, index + 1); activeBuffer = buffers[idx]; upperBound = bufferBounds[idx]; lowerBound = upperBound - activeBuffer.remaining(); lastSegmentIndex = idx; activeBufferLowerBound = lowerBound - activeBuffer.position(); }
/** * Remove element(s) from the set. * * @param elements the element(s) to remove. * @return <tt>true</tt>, if at least one element was found and removed, * or <tt>false</tt> otherwise. */ public final boolean removeAll(Object... elements) { if (elements.length == 0) { return false; } synchronized (sync) { if (array == null) { return false; } boolean result = false; for (Object element : elements) { final T[] oldArray = array; array = ArrayUtils.remove(array, element); result |= (oldArray != array); } return result; } }
/** * Add unique element to the array. * @param <T> type of the array element * @param array array * @param element element to add * * @return array, which will contain the new element. Either new array instance, if * passed array didn't contain the element, or the same array instance, if the element * is already present in the array. */ public static <T> T[] addUnique(T[] array, T element) { return addUnique(array, element, true); }
/** * {@inheritDoc} */ @Override public boolean containsAll(Collection<?> collection) { if (collection.isEmpty()) { return true; } final Object[] localArray = array; for (Object element : collection) { if (ArrayUtils.indexOf(localArray, element) == -1) { return false; } } return true; }
private void recalcIndex(final int index) { final int idx = index < bufferBounds[0] ? 0 : ArrayUtils.binarySearch(bufferBounds, 0, buffersSize - 1, index + 1); activeBuffer = buffers[idx]; upperBound = bufferBounds[idx]; lowerBound = upperBound - activeBuffer.remaining(); lastSegmentIndex = idx; activeBufferLowerBound = lowerBound - activeBuffer.position(); }
/** * Remove element(s) from the set. * * @param elements the element(s) to remove. * @return <tt>true</tt>, if at least one element was found and removed, * or <tt>false</tt> otherwise. */ public final boolean removeAll(Object... elements) { if (elements.length == 0) { return false; } synchronized (sync) { if (array == null) { return false; } boolean result = false; for (Object element : elements) { final T[] oldArray = array; array = ArrayUtils.remove(array, element); result |= (oldArray != array); } return result; } }
/** * Add unique element to the array. * @param <T> type of the array element * @param array array * @param element element to add * * @return array, which will contain the new element. Either new array instance, if * passed array didn't contain the element, or the same array instance, if the element * is already present in the array. */ public static <T> T[] addUnique(T[] array, T element) { return addUnique(array, element, true); }
/** * {@inheritDoc} */ @Override public boolean containsAll(Collection<?> collection) { if (collection.isEmpty()) { return true; } final Object[] localArray = array; for (Object element : collection) { if (ArrayUtils.indexOf(localArray, element) == -1) { return false; } } return true; }
private void recalcIndex(final int index) { final int idx = index < bufferBounds[0] ? 0 : ArrayUtils.binarySearch(bufferBounds, 0, buffersSize - 1, index + 1); activeBuffer = buffers[idx]; upperBound = bufferBounds[idx]; lowerBound = upperBound - activeBuffer.remaining(); lastSegmentIndex = idx; activeBufferLowerBound = lowerBound - activeBuffer.position(); }