Tabnine Logo
IntBigArrays.newBigArray
Code IndexAdd Tabnine to your IDE (free)

How to use
newBigArray
method
in
it.unimi.dsi.fastutil.ints.IntBigArrays

Best Java code snippets using it.unimi.dsi.fastutil.ints.IntBigArrays.newBigArray (Showing top 20 results out of 315)

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 IntBigArrayBigList(final long capacity) {
  if (capacity < 0)
    throw new IllegalArgumentException("Initial capacity (" + capacity + ") is negative");
  if (capacity == 0)
    a = IntBigArrays.EMPTY_BIG_ARRAY;
  else
    a = IntBigArrays.newBigArray(capacity);
}
/**
origin: it.unimi.dsi/fastutil

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

/**
 * Turns a standard array into a big array.
 *
 * <p>
 * Note that the returned big array might contain as a segment the original
 * array.
 *
 * @param array
 *            an array.
 * @return a new big array with the same length and content of {@code array}.
 */
public static int[][] wrap(final int[] array) {
  if (array.length == 0)
    return EMPTY_BIG_ARRAY;
  if (array.length <= SEGMENT_SIZE)
    return new int[][]{array};
  final int[][] bigArray = newBigArray(array.length);
  for (int i = 0; i < bigArray.length; i++)
    System.arraycopy(array, (int) start(i), bigArray[i], 0, bigArray[i].length);
  return bigArray;
}
/**
origin: it.unimi.dsi/fastutil

/** Loads elements from a file given by a {@link File} object, storing them in a new big array.
  *
  * <p>Note that the length of the returned big array will be computed
  * dividing the specified file size by the number of bytes used to
  * represent each element.
  *
  * @param file a file.
  * @return a big array filled with the content of the specified file.
  */
public static int[][] loadIntsBig(final File file) throws IOException {
  final FileInputStream fis = new FileInputStream(file);
  final long length = fis.getChannel().size() / (Integer.SIZE / 8);
  final int[][] array = IntBigArrays.newBigArray(length);
  final DataInputStream dis = new DataInputStream(new FastBufferedInputStream(fis));
  for(int i = 0; i < array.length; i++) {
   final int[] t = array[i];
   final int l = t.length;
   for(int d = 0; d < l; d++) t[d] = dis.readInt();
  }
  dis.close();
  return array;
}
/** Loads elements from a file given by a filename, storing them in a new big array.
origin: it.unimi.dsi/fastutil

public static void main(final String arg[]) {
  int[][] a = IntBigArrays.newBigArray(1L << Integer.parseInt(arg[0]));
  long x, y, z, start;
origin: it.unimi.dsi/mg4j-big

/** Utility method to load a compressed size file into a list.
 *
 * @param filename the filename containing the &gamma;-coded sizes (see {@link BitStreamIndexWriter}).
 * @param N the number of documents.
 * @return a list of integers backed by an array.
 */
public static IntBigList readSizes( final CharSequence filename, final long N ) throws IOException {
  final int[][] size = IntBigArrays.newBigArray( N );
  final InputBitStream in = new InputBitStream( filename.toString() );
  LOGGER.debug( "Loading sizes..." );
  for( int segment = 0; segment < size.length; segment++ ) in.readGammas( size[ segment ], size[ segment ].length );		  
  LOGGER.debug( "Completed." );
  in.close();
  return IntBigArrayBigList.wrap( size );
}
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 int[][] copy(final int[][] array, final long offset, final long length) {
  ensureOffsetLength(array, offset, length);
  final int[][] a = newBigArray(length);
  copy(array, offset, a, 0, length);
  return a;
}
/**
origin: it.unimi.dsi/fastutil

/**
 * Creates a new hash big set.
 *
 * <p>
 * The actual table size will be the least power of two greater than
 * {@code expected}/{@code f}.
 *
 * @param expected
 *            the expected number of elements in the set.
 * @param f
 *            the load factor.
 */
public IntOpenHashBigSet(final long expected, final float f) {
  if (f <= 0 || f > 1)
    throw new IllegalArgumentException("Load factor must be greater than 0 and smaller than or equal to 1");
  if (n < 0)
    throw new IllegalArgumentException("The expected number of elements must be nonnegative");
  this.f = f;
  minN = n = bigArraySize(expected, f);
  maxFill = maxFill(n, f);
  key = IntBigArrays.newBigArray(n);
  initMasks();
}
/**
origin: it.unimi.dsi/mg4j-big

protected int combineSizes( final OutputBitStream sizesOutputBitStream ) throws IOException {
  int maxDocSize = 0, currDoc = 0;
  if ( needsSizes ) size = IntBigArrays.newBigArray( numberOfDocuments );
  for( int i = 0; i < numIndices; i++ ) {
    final IntIterator sizes = sizes( i );
    int s = 0;
    long j = index[ i ].numberOfDocuments;
    while( j-- != 0 ) {
      maxDocSize = Math.max( maxDocSize, s = sizes.nextInt() );
      if ( needsSizes ) IntBigArrays.set( size, currDoc++, s );
      sizesOutputBitStream.writeGamma( s );
    }
    if ( sizes instanceof Closeable ) ((Closeable)sizes).close();
  }
  return maxDocSize;
}
origin: it.unimi.di/mg4j-big

protected int combineSizes( final OutputBitStream sizesOutputBitStream ) throws IOException {
  int maxDocSize = 0, currDoc = 0;
  if ( needsSizes ) size = IntBigArrays.newBigArray( numberOfDocuments );
  for( int i = 0; i < numIndices; i++ ) {
    final IntIterator sizes = sizes( i );
    int s = 0;
    long j = index[ i ].numberOfDocuments;
    while( j-- != 0 ) {
      maxDocSize = Math.max( maxDocSize, s = sizes.nextInt() );
      if ( needsSizes ) IntBigArrays.set( size, currDoc++, s );
      sizesOutputBitStream.writeGamma( s );
    }
    if ( sizes instanceof Closeable ) ((Closeable)sizes).close();
  }
  return maxDocSize;
}
origin: it.unimi.di/mg4j-big

/** Utility method to load a compressed size file into a list.
 *
 * @param ioFactory the factory that will be used to perform I/O.
 * @param filename the file containing the &gamma;-coded sizes (see {@link BitStreamIndexWriter}).
 * @param n the number of documents.
 * @return a list of integers backed by an array.
 */
public static IntBigArrayBigList readSizes( final IOFactory ioFactory, final CharSequence filename, final long n ) throws IOException {
  final int[][] size = IntBigArrays.newBigArray( n );
  final InputBitStream in = new InputBitStream( ioFactory.getInputStream( filename.toString() ), false );
  LOGGER.debug( "Loading sizes..." );
  for( int segment = 0; segment < size.length; segment++ ) in.readGammas( size[ segment ], size[ segment ].length );		  
  LOGGER.debug( "Completed." );
  in.close();
  return IntBigArrayBigList.wrap( size );
}
origin: it.unimi.di/mg4j-big

protected int combineSizes( final OutputBitStream sizesOutputBitStream ) throws IOException {
  int curSize, s, maxDocSize = 0;
  if ( needsSizes ) size = IntBigArrays.newBigArray( numberOfDocuments );
  
  final IntIterator[] sizes = new IntIterator[ numIndices ];
  for( int i = 0; i < numIndices; i++ ) sizes[ i ] = sizes( i );
  
  for( int d = 0; d < numberOfDocuments; d++ ) {
    curSize = 0;
    for( int i = 0; i < numIndices; i++ ) {
      if ( d < index[ i ].numberOfDocuments && ( s = sizes[ i ].nextInt() ) != 0 ) {
        if ( curSize != 0 ) throw new IllegalArgumentException( "Document " + d + " has nonzero length in two indices" );
        curSize = s;
      }
    }
    if ( needsSizes ) IntBigArrays.set( size, d, curSize );
    if ( curSize > maxDocSize ) maxDocSize = curSize;
    sizesOutputBitStream.writeGamma( curSize );
  }
  for( int i = 0; i < numIndices; i++ ) if ( sizes[ i ] instanceof Closeable ) ((Closeable)sizes[ i ]).close();
  return maxDocSize;
}
origin: it.unimi.dsi/mg4j-big

protected int combineSizes( final OutputBitStream sizesOutputBitStream ) throws IOException {
  int curSize, s, maxDocSize = 0;
  if ( needsSizes ) size = IntBigArrays.newBigArray( numberOfDocuments );
  
  final IntIterator[] sizes = new IntIterator[ numIndices ];
  for( int i = 0; i < numIndices; i++ ) sizes[ i ] = sizes( i );
  
  for( int d = 0; d < numberOfDocuments; d++ ) {
    curSize = 0;
    for( int i = 0; i < numIndices; i++ ) {
      if ( d < index[ i ].numberOfDocuments && ( s = sizes[ i ].nextInt() ) != 0 ) {
        if ( curSize != 0 ) throw new IllegalArgumentException( "Document " + d + " has nonzero length in two indices" );
        curSize = s;
      }
    }
    if ( needsSizes ) IntBigArrays.set( size, d, curSize );
    if ( curSize > maxDocSize ) maxDocSize = curSize;
    sizesOutputBitStream.writeGamma( curSize );
  }
  for( int i = 0; i < numIndices; i++ ) if ( sizes[ i ] instanceof Closeable ) ((Closeable)sizes[ i ]).close();
  return maxDocSize;
}
origin: it.unimi.dsi/fastutil

private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
  s.defaultReadObject();
  n = bigArraySize(size, f);
  maxFill = maxFill(n, f);
  final int[][] key = this.key = IntBigArrays.newBigArray(n);
  initMasks();
  long h;
  int k;
  int base, displ;
  for (long i = size; i-- != 0;) {
    k = s.readInt();
    if (((k) == (0)))
      containsNull = true;
    else {
      h = (it.unimi.dsi.fastutil.HashCommon.mix((long) ((k))));
      if (!((key[base = (int) ((h & mask) >>> BigArrays.SEGMENT_SHIFT)][displ = (int) (h
          & segmentMask)]) == (0)))
        while (!((key[base = (base + ((displ = (displ + 1) & segmentMask) == 0 ? 1 : 0))
            & baseMask][displ]) == (0)));
      key[base][displ] = k;
    }
  }
  if (ASSERTS)
    checkTable();
}
private void checkTable() {
origin: it.unimi.dsi/webgraph

/**
 * Creates a new hash big set.
 *
 * <p>The actual table size will be the least power of two greater than
 * <code>expected</code>/<code>f</code>.
 *
 * @param expected the expected number of elements in the set.
 * @param f the load factor.
 */
public Long2IntOpenHashBigMap(final long expected, final float f) {
  if (f <= 0 || f > 1) throw new IllegalArgumentException("Load factor must be greater than 0 and smaller than or equal to 1");
  if (n < 0) throw new IllegalArgumentException("The expected number of elements must be nonnegative");
  this.f = f;
  n = bigArraySize(expected, f);
  maxFill = maxFill(n, f);
  key = LongBigArrays.newBigArray(n);
  value = IntBigArrays.newBigArray(n);
  used = BooleanBigArrays.newBigArray(n);
  initMasks();
}
origin: it.unimi.dsi/mg4j-big

size = IntBigArrays.newBigArray( numberOfDocuments );
for( int i = 0; i < numIndices; i++ ) {
  final IntIterator sizes = sizes( i );
size = IntBigArrays.newBigArray( numberOfDocuments );
final IntIterator sizes = sizes( numIndices - 1 );
int s = 0;
origin: it.unimi.di/mg4j-big

size = IntBigArrays.newBigArray( numberOfDocuments );
for( int i = 0; i < numIndices; i++ ) {
  final IntIterator sizes = sizes( i );
size = IntBigArrays.newBigArray( numberOfDocuments );
final IntIterator sizes = sizes( numIndices - 1 );
int s = 0;
origin: it.unimi.di/mg4j-big

if ( indexingIsVirtual && virtualDocumentGap == 0 ) throw new IllegalArgumentException( "Illegal virtual document gap: " + virtualDocumentGap );
if ( indexingIsVirtual ) currSize = IntBigArrays.newBigArray( numVirtualDocs );
maxDocInBatch = ( currSize != null ? IntBigArrays.length( currSize ) : 0 ) -1;
openSizeBitStream();
origin: it.unimi.dsi/fastutil

final int newKey[][] = IntBigArrays.newBigArray(newN);
final long mask = newN - 1; // Note that this is used by the hashing macro
final int newSegmentMask = newKey[0].length - 1;
origin: it.unimi.dsi/webgraph

final boolean newUsed[][] = BooleanBigArrays.newBigArray(newN);
final long newKey[][] = LongBigArrays.newBigArray(newN);
final int newValue[][] = IntBigArrays.newBigArray(newN);
final long newMask = newN - 1;
final int newSegmentMask = newKey[0].length - 1;
it.unimi.dsi.fastutil.intsIntBigArraysnewBigArray

Javadoc

Creates a new big array.

Popular methods of IntBigArrays

  • get
    Returns the element of the given big array of specified index.
  • set
    Sets the element of the given big array of specified index.
  • length
    Returns the length of the given big array.
  • binarySearch
    Searches a range of the specified big array for the specified value using the binary search algorith
  • 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
  • forceCapacity
    Forces a big array to contain the given number of entries, preserving just a part of the big array.W
  • fill,
  • forceCapacity,
  • grow,
  • med3,
  • quickSort,
  • radixSort,
  • selectionSort,
  • swap,
  • trim

Popular in Java

  • Finding current android device location
  • getExternalFilesDir (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getResourceAsStream (ClassLoader)
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top Sublime Text plugins
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