Tabnine Logo
LongBigArrays
Code IndexAdd Tabnine to your IDE (free)

How to use
LongBigArrays
in
it.unimi.dsi.fastutil.longs

Best Java code snippets using it.unimi.dsi.fastutil.longs.LongBigArrays (Showing top 20 results out of 315)

origin: it.unimi.dsi/fastutil

  private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
    s.defaultReadObject();
    a = LongBigArrays.newBigArray(size);
    for (int i = 0; i < size; i++)
      LongBigArrays.set(a, i, s.readLong());
  }
}
origin: it.unimi.dsi/fastutil

@Override
public long set(final long index, final long k) {
  if (index >= size)
    throw new IndexOutOfBoundsException(
        "Index (" + index + ") is greater than or equal to list size (" + size + ")");
  long old = LongBigArrays.get(a, index);
  LongBigArrays.set(a, index, k);
  return old;
}
@Override
origin: it.unimi.dsi/fastutil

  /**
   * Shuffles the specified big array using the specified pseudorandom number
   * generator.
   *
   * @param a
   *            the big array to be shuffled.
   * @param random
   *            a pseudorandom number generator.
   * @return {@code a}.
   */
  public static long[][] shuffle(final long[][] a, final Random random) {
    for (long i = length(a); i-- != 0;) {
      final long p = (random.nextLong() & 0x7FFFFFFFFFFFFFFFL) % (i + 1);
      final long t = get(a, i);
      set(a, i, get(a, p));
      set(a, p, t);
    }
    return a;
  }
}
origin: it.unimi.dsi/fastutil

@Override
public void size(final long size) {
  if (size > LongBigArrays.length(a))
    a = LongBigArrays.forceCapacity(a, size, this.size);
  if (size > this.size)
    LongBigArrays.fill(a, this.size, size, (0));
  this.size = size;
}
@Override
origin: it.unimi.dsi/fastutil

private static void selectionSort(final long[][] a, final long from, final long to) {
  for (long i = from; i < to - 1; i++) {
    long m = i;
    for (long j = i + 1; j < to; j++)
      if (((LongBigArrays.get(a, j)) < (LongBigArrays.get(a, m))))
        m = j;
    if (m != i)
      swap(a, i, m);
  }
}
/**
origin: it.unimi.dsi/fastutil

@Override
public long removeLong(final long index) {
  if (index >= size)
    throw new IndexOutOfBoundsException(
        "Index (" + index + ") is greater than or equal to list size (" + size + ")");
  final long old = LongBigArrays.get(a, index);
  size--;
  if (index != size)
    LongBigArrays.copy(a, index + 1, a, index, size - index);
  assert size <= LongBigArrays.length(a);
  return old;
}
@Override
origin: it.unimi.dsi/fastutil

/**
 * Creates a new big-array big list with given capacity.
 *
 * @param capacity
 *            the initial capacity of the array list (may be 0).
 */
public LongBigArrayBigList(final long capacity) {
  if (capacity < 0)
    throw new IllegalArgumentException("Initial capacity (" + capacity + ") is negative");
  if (capacity == 0)
    a = LongBigArrays.EMPTY_BIG_ARRAY;
  else
    a = LongBigArrays.newBigArray(capacity);
}
/**
origin: it.unimi.dsi/fastutil

@Override
public long lastIndexOf(final long k) {
  for (long i = size; i-- != 0;)
    if (((k) == (LongBigArrays.get(a, i))))
      return i;
  return -1;
}
@Override
origin: it.unimi.dsi/fastutil

if (LongBigArrays.length(a) != LongBigArrays.length(b))
  throw new IllegalArgumentException("Array size mismatch.");
final int maxLevel = DIGITS_PER_ELEMENT * layers - 1;
  final int signMask = level % DIGITS_PER_ELEMENT == 0 ? 1 << DIGIT_BITS - 1 : 0;
  if (length < MEDIUM) {
    selectionSort(a, b, first, first + length);
    continue;
        (byte) ((((LongBigArrays.get(k, first + i)) >>> shift) & DIGIT_MASK) ^ signMask));
  for (long i = length; i-- != 0;)
    count[ByteBigArrays.get(digit, i) & 0xFF]++;
    long t = LongBigArrays.get(a, i + first);
    long u = LongBigArrays.get(b, i + first);
    c = ByteBigArrays.get(digit, i) & 0xFF;
    while ((d = --pos[c]) > i) {
      long z = t;
      final int zz = c;
      t = LongBigArrays.get(a, d + first);
      LongBigArrays.set(a, d + first, z);
      z = u;
      u = LongBigArrays.get(b, d + first);
      LongBigArrays.set(b, d + first, z);
      c = ByteBigArrays.get(digit, d) & 0xFF;
      ByteBigArrays.set(digit, d, (byte) zz);
    LongBigArrays.set(a, i + first, t);
    LongBigArrays.set(b, i + first, u);
origin: it.unimi.dsi/fastutil

  selectionSort(x, from, to);
  return;
  if (len > MEDIUM) { // Big arrays, pseudomedian of 9
    long s = len / 8;
    l = med3(x, l, l + s, l + 2 * s);
    m = med3(x, m - s, m, m + s);
    n = med3(x, n - 2 * s, n - s, n);
  m = med3(x, l, m, n); // Mid-size, med of 3
final long v = get(x, m);
  while (b <= c && (comparison = (Long.compare((get(x, b)), (v)))) <= 0) {
    if (comparison == 0)
      swap(x, a++, b);
    b++;
  while (c >= b && (comparison = (Long.compare((get(x, c)), (v)))) >= 0) {
    if (comparison == 0)
      swap(x, c, d--);
    c--;
  swap(x, b++, c--);
vecSwap(x, from, b - s, s);
s = Math.min(d - c, n - d - 1);
vecSwap(x, b, n - s, s);
origin: it.unimi.dsi/fastutil

/**
 * Returns a copy of a portion of a big array.
 *
 * @param array
 *            a big array.
 * @param offset
 *            the first element to copy.
 * @param length
 *            the number of elements to copy.
 * @return a new big array containing {@code length} elements of {@code array}
 *         starting at {@code offset}.
 */
public static long[][] copy(final long[][] array, final long offset, final long length) {
  ensureOffsetLength(array, offset, length);
  final long[][] a = newBigArray(length);
  copy(array, offset, a, 0, length);
  return a;
}
/**
origin: it.unimi.dsi/fastutil

final int signMask = level % DIGITS_PER_ELEMENT == 0 ? 1 << DIGIT_BITS - 1 : 0;
if (length < MEDIUM) {
  selectionSort(a, first, first + length);
  continue;
      (byte) ((((LongBigArrays.get(a, first + i)) >>> shift) & DIGIT_MASK) ^ signMask));
for (long i = length; i-- != 0;)
  count[ByteBigArrays.get(digit, i) & 0xFF]++;
  long t = LongBigArrays.get(a, i + first);
  c = ByteBigArrays.get(digit, i) & 0xFF;
  while ((d = --pos[c]) > i) {
    final long z = t;
    final int zz = c;
    t = LongBigArrays.get(a, d + first);
    c = ByteBigArrays.get(digit, d) & 0xFF;
    LongBigArrays.set(a, d + first, z);
    ByteBigArrays.set(digit, d, (byte) zz);
  LongBigArrays.set(a, i + first, t);
origin: it.unimi.dsi/fastutil

@Override
public void add(final long index, final long k) {
  ensureIndex(index);
  grow(size + 1);
  if (index != size)
    LongBigArrays.copy(a, index, a, index + 1, size - index);
  LongBigArrays.set(a, index, k);
  size++;
  assert size <= LongBigArrays.length(a);
}
@Override
origin: it.unimi.dsi/dsiutils

/** Computes the inverse of a permutation expressed
 * as a {@linkplain BigArrays big array} of <var>n</var> distinct long integers in [0&nbsp;..&nbsp;<var>n</var>)
 * and stores the result in a new big array.
 *
 * <p><strong>Warning</strong>: if <code>perm</code> is not a permutation,
 * essentially anything can happen.
 *
 * @param perm the permutation to be inverted.
 * @return a new big array containing the inverse permutation.
 */
public static long[][] invertPermutation(long[][] perm) {
  return invertPermutation(perm, LongBigArrays.newBigArray(LongBigArrays.length(perm)));
}
origin: it.unimi.dsi/fastutil

@Override
public void clear() {
  size = 0;
  assert size <= LongBigArrays.length(a);
}
@Override
origin: it.unimi.dsi/fastutil

@Override
public boolean add(final long k) {
  grow(size + 1);
  LongBigArrays.set(a, size++, k);
  assert size <= LongBigArrays.length(a);
  return true;
}
@Override
origin: it.unimi.dsi/fastutil

public static String toString(final long[][] a) {
  if (a == null)
    return "null";
  final long last = length(a) - 1;
  if (last == -1)
    return "[]";
  final StringBuilder b = new StringBuilder();
  b.append('[');
  for (long i = 0;; i++) {
    b.append(String.valueOf(get(a, i)));
    if (i == last)
      return b.append(']').toString();
    b.append(", ");
  }
}
/**
origin: it.unimi.dsi/fastutil

/**
 * {@inheritDoc}
 *
 * <p>
 * This is a trivial iterator-based implementation. It is expected that
 * implementations will override this method with a more optimized version.
 */
@Override
public void getElements(final long from, final long a[][], long offset, long length) {
  LongBigListIterator i = listIterator(from);
  LongBigArrays.ensureOffsetLength(a, offset, length);
  if (from + length > size64())
    throw new IndexOutOfBoundsException(
        "End index (" + (from + length) + ") is greater than list size (" + size64() + ")");
  while (length-- != 0)
    LongBigArrays.set(a, offset++, i.nextLong());
}
/**
origin: it.unimi.dsi/fastutil

/**
 * Writes a length.
 * 
 * @param a
 *            the data array.
 * @param length
 *            the length to be written.
 * @param pos
 *            the starting position.
 * @return the number of elements coding {@code length}.
 */
private static int writeInt(final long a[][], int length, long pos) {
  LongBigArrays.set(a, pos, length);
  return 1;
}
/**
origin: it.unimi.dsi/fastutil

/**
 * Ensures that this big-array big list can contain the given number of entries
 * without resizing.
 *
 * @param capacity
 *            the new minimum capacity for this big-array big list.
 */
public void ensureCapacity(final long capacity) {
  if (capacity <= a.length || a == LongBigArrays.DEFAULT_EMPTY_BIG_ARRAY)
    return;
  a = LongBigArrays.forceCapacity(a, capacity, size);
  assert size <= LongBigArrays.length(a);
}
/**
it.unimi.dsi.fastutil.longsLongBigArrays

Javadoc

A class providing static methods and objects that do useful things with BigArrays.

In particular, the forceCapacity(), ensureCapacity(), grow(), trim() and setLength() methods allow to handle big arrays much like array lists.

Note that it.unimi.dsi.fastutil.io.BinIO and it.unimi.dsi.fastutil.io.TextIO contain several methods that make it possible to load and save big arrays of primitive types as sequences of elements in java.io.DataInput format (i.e., not as objects) or as sequences of lines of text.

Most used methods

  • newBigArray
    Creates a new big array.
  • set
    Sets the element of the given big array of specified index.
  • get
    Returns the element of the given big array of specified index.
  • length
    Returns the length of the given big array.
  • binarySearch
    Searches a big array for the specified value using the binary search algorithm and a specified compa
  • copy
    Copies a big array from the specified source big array, beginning at the specified position, to the
  • copyFromBig
    Copies a big array from the specified source big array, beginning at the specified position, to the
  • copyToBig
    Copies an array from the specified source array, beginning at the specified position, to the specifi
  • ensureCapacity
    Ensures that a big array can contain the given number of entries, preserving just a part of the big
  • ensureOffsetLength
    Ensures that a range given by an offset and a length fits a big array. This method may be used whene
  • equals
    Returns true if the two big arrays are elementwise equal. This method uses a backward loop. It is si
  • fill
    Fills a portion of the given big array with the given value. If possible (i.e., from is 0) this meth
  • equals,
  • fill,
  • forceCapacity,
  • grow,
  • med3,
  • quickSort,
  • radixSort,
  • selectionSort,
  • swap,
  • trim

Popular in Java

  • Finding current android device location
  • scheduleAtFixedRate (Timer)
  • addToBackStack (FragmentTransaction)
  • onRequestPermissionsResult (Fragment)
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Collectors (java.util.stream)
  • 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