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

How to use
ArraySet
in
com.lody.virtual.helper.collection

Best Java code snippets using com.lody.virtual.helper.collection.ArraySet (Showing top 20 results out of 315)

origin: android-hacker/VirtualXposed

/**
 * Perform a {@link #add(Object)} of all values in <var>array</var>
 * @param array The array whose contents are to be retrieved.
 */
public void addAll(ArraySet<? extends E> array) {
  final int N = array.mSize;
  ensureCapacity(mSize + N);
  if (mSize == 0) {
    if (N > 0) {
      System.arraycopy(array.mHashes, 0, mHashes, 0, N);
      System.arraycopy(array.mArray, 0, mArray, 0, N);
      mSize = N;
    }
  } else {
    for (int i=0; i<N; i++) {
      add(array.valueAt(i));
    }
  }
}
origin: android-hacker/VirtualXposed

/** {@hide} */
public ArraySet(Collection<E> set) {
  this();
  if (set != null) {
    addAll(set);
  }
}
origin: android-hacker/VirtualXposed

if (value == null) {
  hash = 0;
  index = indexOfNull();
} else {
  hash = value.hashCode();
  index = indexOf(value, hash);
  allocArrays(n);
  freeArrays(ohashes, oarray, mSize);
origin: android-hacker/VirtualXposed

/**
 * Removes the specified object from this set.
 *
 * @param object the object to remove.
 * @return {@code true} if this set was modified, {@code false} otherwise.
 */
@Override
public boolean remove(Object object) {
  final int index = indexOf(object);
  if (index >= 0) {
    removeAt(index);
    return true;
  }
  return false;
}
origin: android-hacker/VirtualXposed

/**
 * Returns the index of a value in the set.
 *
 * @param key The value to search for.
 * @return Returns the index of the value if it exists, else a negative integer.
 */
public int indexOf(Object key) {
  return key == null ? indexOfNull() : indexOf(key, key.hashCode());
}
origin: android-hacker/VirtualXposed

/**
 * Perform an {@link #add(Object)} of all values in <var>collection</var>
 * @param collection The collection whose contents are to be retrieved.
 */
@Override
public boolean addAll(Collection<? extends E> collection) {
  ensureCapacity(mSize + collection.size());
  boolean added = false;
  for (E value : collection) {
    added |= add(value);
  }
  return added;
}
origin: android-hacker/VirtualXposed

/**
 * Ensure the array map can hold at least <var>minimumCapacity</var>
 * items.
 */
public void ensureCapacity(int minimumCapacity) {
  if (mHashes.length < minimumCapacity) {
    final int[] ohashes = mHashes;
    final Object[] oarray = mArray;
    allocArrays(minimumCapacity);
    if (mSize > 0) {
      System.arraycopy(ohashes, 0, mHashes, 0, mSize);
      System.arraycopy(oarray, 0, mArray, 0, mSize);
    }
    freeArrays(ohashes, oarray, mSize);
  }
}
origin: android-hacker/VirtualXposed

/**
 * Check whether a value exists in the set.
 *
 * @param key The value to search for.
 * @return Returns true if the value exists, else false.
 */
@Override
public boolean contains(Object key) {
  return indexOf(key) >= 0;
}
origin: android-hacker/VirtualXposed

/**
 * Return an {@link java.util.Iterator} over all values in the set.
 *
 * <p><b>Note:</b> this is a fairly inefficient way to access the array contents, it
 * requires generating a number of temporary objects and allocates additional state
 * information associated with the container that will remain for the life of the container.</p>
 */
@Override
public Iterator<E> iterator() {
  return getCollection().getKeySet().iterator();
}
origin: android-hacker/VirtualXposed

/**
 * Make the array map empty.  All storage is released.
 */
@Override
public void clear() {
  if (mSize != 0) {
    freeArrays(mHashes, mArray, mSize);
    mHashes = ContainerHelpers.EMPTY_INTS;
    mArray = ContainerHelpers.EMPTY_OBJECTS;
    mSize = 0;
  }
}
origin: android-hacker/VirtualXposed

  @Override
  protected void colClear() {
    clear();
  }
};
origin: android-hacker/VirtualXposed

/**
 * Create a new ArraySet with a given initial capacity.
 */
public ArraySet(int capacity) {
  if (capacity == 0) {
    mHashes = ContainerHelpers.EMPTY_INTS;
    mArray = ContainerHelpers.EMPTY_OBJECTS;
  } else {
    allocArrays(capacity);
  }
  mSize = 0;
}
origin: android-hacker/VirtualXposed

@Override
protected void colPut(E key, E value) {
  add(key);
}
origin: android-hacker/VirtualXposed

/**
 * Determine if the array set contains all of the values in the given collection.
 * @param collection The collection whose contents are to be checked against.
 * @return Returns true if this array set contains a value for every entry
 * in <var>collection</var>, else returns false.
 */
@Override
public boolean containsAll(Collection<?> collection) {
  Iterator<?> it = collection.iterator();
  while (it.hasNext()) {
    if (!contains(it.next())) {
      return false;
    }
  }
  return true;
}
origin: android-hacker/VirtualXposed

@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
  int uid = (int) args[0];
  int callingUid = Binder.getCallingUid();
  if (uid == VirtualCore.get().myUid()) {
    uid = getBaseVUid();
  }
  String[] callingPkgs = VPackageManager.get().getPackagesForUid(callingUid);
  String[] targetPkgs = VPackageManager.get().getPackagesForUid(uid);
  String[] selfPkgs = VPackageManager.get().getPackagesForUid(Process.myUid());
  Set<String> pkgList = new ArraySet<>(2);
  if (callingPkgs != null && callingPkgs.length > 0) {
    pkgList.addAll(Arrays.asList(callingPkgs));
  }
  if (targetPkgs != null && targetPkgs.length > 0) {
    pkgList.addAll(Arrays.asList(targetPkgs));
  }
  if (selfPkgs != null && selfPkgs.length > 0) {
    pkgList.addAll(Arrays.asList(selfPkgs));
  }
  return pkgList.toArray(new String[pkgList.size()]);
}
origin: android-hacker/VirtualXposed

freeArrays(mHashes, mArray, mSize);
mHashes = ContainerHelpers.EMPTY_INTS;
mArray = ContainerHelpers.EMPTY_OBJECTS;
  allocArrays(n);
origin: darkskygit/VirtualApp

/**
 * Returns the index of a value in the set.
 *
 * @param key The value to search for.
 * @return Returns the index of the value if it exists, else a negative integer.
 */
public int indexOf(Object key) {
  return key == null ? indexOfNull() : indexOf(key, key.hashCode());
}
origin: darkskygit/VirtualApp

/**
 * Perform an {@link #add(Object)} of all values in <var>collection</var>
 * @param collection The collection whose contents are to be retrieved.
 */
@Override
public boolean addAll(Collection<? extends E> collection) {
  ensureCapacity(mSize + collection.size());
  boolean added = false;
  for (E value : collection) {
    added |= add(value);
  }
  return added;
}
origin: darkskygit/VirtualApp

/**
 * Removes the specified object from this set.
 *
 * @param object the object to remove.
 * @return {@code true} if this set was modified, {@code false} otherwise.
 */
@Override
public boolean remove(Object object) {
  final int index = indexOf(object);
  if (index >= 0) {
    removeAt(index);
    return true;
  }
  return false;
}
origin: android-hacker/VirtualXposed

@Override
protected int colIndexOfKey(Object key) {
  return indexOf(key);
}
com.lody.virtual.helper.collectionArraySet

Javadoc

ArraySet is a generic set data structure that is designed to be more memory efficient than a traditional java.util.HashSet. The design is very similar to ArrayMap, with all of the caveats described there. This implementation is separate from ArrayMap, however, so the Object array contains only one item for each entry in the set (instead of a pair for a mapping).

Note that this implementation is not intended to be appropriate for data structures that may contain large numbers of items. It is generally slower than a traditional HashSet, since lookups require a binary search and adds and removes require inserting and deleting entries in the array. For containers holding up to hundreds of items, the performance difference is not significant, less than 50%.

Because this container is intended to better balance memory use, unlike most other standard Java containers it will shrink its array as items are removed from it. Currently you have no control over this shrinking -- if you set a capacity and then remove an item, it may reduce the capacity to better match the current size. In the future an explicit call to set the capacity should turn off this aggressive shrinking behavior.

Most used methods

  • <init>
  • add
    Adds the specified object to this set. The set is not modified if it already contains the object.
  • addAll
    Perform an #add(Object) of all values in collection
  • allocArrays
  • clear
    Make the array map empty. All storage is released.
  • contains
    Check whether a value exists in the set.
  • ensureCapacity
    Ensure the array map can hold at least minimumCapacity items.
  • freeArrays
  • getCollection
  • indexOf
  • indexOfNull
  • isEmpty
    Return true if the array map contains no items.
  • indexOfNull,
  • isEmpty,
  • remove,
  • removeAt,
  • size,
  • valueAt

Popular in Java

  • Running tasks concurrently on multiple threads
  • getExternalFilesDir (Context)
  • compareTo (BigDecimal)
  • getContentResolver (Context)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Option (scala)
  • Top Vim 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