Tabnine Logo
BooleanArrays.trim
Code IndexAdd Tabnine to your IDE (free)

How to use
trim
method
in
it.unimi.dsi.fastutil.booleans.BooleanArrays

Best Java code snippets using it.unimi.dsi.fastutil.booleans.BooleanArrays.trim (Showing top 4 results out of 315)

origin: AliView/AliView

/** Sets the length of the given array.
  *
  * @param array an array.
  * @param length the new length for the array.
  * @return <code>array</code>, if it contains exactly <code>length</code>
  * entries; otherwise, if it contains <em>more</em> than
  * <code>length</code> entries, an array with <code>length</code> entries
  * whose entries are the same as the first <code>length</code> entries of
  * <code>array</code>; otherwise, an array with <code>length</code> entries
  * whose first <code>array.length</code> entries are the same as those of
  * <code>array</code>.
  * 
  */
public static boolean[] setLength( final boolean[] array, final int length ) {
if ( length == array.length ) return array;
if ( length < array.length ) return trim( array, length );
return ensureCapacity( array, length );
}
/** Returns a copy of a portion of an array.
origin: it.unimi.dsi/fastutil

/**
 * Sets the length of the given array.
 *
 * @param array
 *            an array.
 * @param length
 *            the new length for the array.
 * @return {@code array}, if it contains exactly {@code length} entries;
 *         otherwise, if it contains <em>more</em> than {@code length} entries,
 *         an array with {@code length} entries whose entries are the same as
 *         the first {@code length} entries of {@code array}; otherwise, an
 *         array with {@code length} entries whose first {@code array.length}
 *         entries are the same as those of {@code array}.
 *
 */
public static boolean[] setLength(final boolean[] array, final int length) {
  if (length == array.length)
    return array;
  if (length < array.length)
    return trim(array, length);
  return ensureCapacity(array, length);
}
/**
origin: it.unimi.dsi/fastutil

/**
 * Trims the given big array to the given length.
 *
 * <p>
 * <strong>Warning:</strong> the returned array might use part of the segments
 * of the original array, which must be considered read-only after calling this
 * method.
 *
 * @param array
 *            a big array.
 * @param length
 *            the new maximum length for the big array.
 * @return {@code array}, if it contains {@code length} entries or less;
 *         otherwise, a big array with {@code length} entries whose entries are
 *         the same as the first {@code length} entries of {@code array}.
 *
 */
public static boolean[][] trim(final boolean[][] array, final long length) {
  ensureLength(length);
  final long oldLength = length(array);
  if (length >= oldLength)
    return array;
  final int baseLength = (int) ((length + SEGMENT_MASK) >>> SEGMENT_SHIFT);
  final boolean[][] base = Arrays.copyOf(array, baseLength);
  final int residual = (int) (length & SEGMENT_MASK);
  if (residual != 0)
    base[baseLength - 1] = BooleanArrays.trim(base[baseLength - 1], residual);
  return base;
}
/**
origin: it.unimi.dsi/fastutil

/**
 * Unwraps an iterator, returning an array, with a limit on the number of
 * elements.
 *
 * <p>
 * This method iterates over the given type-specific iterator and returns an
 * array containing the elements returned by the iterator. At most {@code max}
 * elements will be returned.
 *
 * @param i
 *            a type-specific iterator.
 * @param max
 *            the maximum number of elements to be unwrapped.
 * @return an array containing the elements returned by the iterator (at most
 *         {@code max}).
 */
public static boolean[] unwrap(final BooleanIterator i, int max) {
  if (max < 0)
    throw new IllegalArgumentException("The maximum number of elements (" + max + ") is negative");
  boolean array[] = new boolean[16];
  int j = 0;
  while (max-- != 0 && i.hasNext()) {
    if (j == array.length)
      array = BooleanArrays.grow(array, j + 1);
    array[j++] = i.nextBoolean();
  }
  return BooleanArrays.trim(array, j);
}
/**
it.unimi.dsi.fastutil.booleansBooleanArraystrim

Javadoc

Trims the given array to the given length.

Popular methods of BooleanArrays

  • quickSort
    Sorts the specified range of elements of two arrays according to the natural lexicographical ascendi
  • ensureCapacity
    Ensures that an array can contain the given number of entries, preserving just a part of the array.
  • ensureFromTo
    Ensures that a range given by its first (inclusive) and last (exclusive) elements fits an array. Thi
  • ensureOffsetLength
    Ensures that a range given by an offset and a length fits an array. This method may be used whenever
  • fill
    Fills the given array with the given value.
  • insertionSort
  • med3
  • mergeSort
    Sorts an array according to the order induced by the specified comparator using mergesort. This sort
  • selectionSort
  • swap
  • ensureSameLength
    Ensures that two arrays are of the same length.
  • equals
    Returns true if the two arrays are elementwise equal.
  • ensureSameLength,
  • equals,
  • forceCapacity,
  • grow,
  • insertionSortIndirect,
  • med3Indirect,
  • parallelQuickSort,
  • parallelQuickSortIndirect,
  • quickSortIndirect

Popular in Java

  • Start an intent from android
  • putExtra (Intent)
  • setContentView (Activity)
  • requestLocationUpdates (LocationManager)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • JComboBox (javax.swing)
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Runner (org.openjdk.jmh.runner)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now