Codota Logo
Iterate.sizeOf
Code IndexAdd Codota to your IDE (free)

How to use
sizeOf
method
in
com.gs.collections.impl.utility.Iterate

Best Java code snippets using com.gs.collections.impl.utility.Iterate.sizeOf (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ScheduledThreadPoolExecutor s =
  • Codota Iconnew ScheduledThreadPoolExecutor(corePoolSize)
  • Codota IconThreadFactory threadFactory;new ScheduledThreadPoolExecutor(corePoolSize, threadFactory)
  • Codota IconString str;new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder().setNameFormat(str).build())
  • Smart code suggestions by Codota
}
origin: goldmansachs/gs-collections

  public int intValueOf(Iterable<?> iterable)
  {
    return Iterate.sizeOf(iterable);
  }
}
origin: goldmansachs/gs-collections

@Override
public int size()
{
  return Iterate.sizeOf(this.adapted);
}
origin: goldmansachs/gs-collections

@Override
public int size()
{
  return Iterate.sizeOf(this.adapted);
}
origin: goldmansachs/gs-collections

public static <T, BT extends ObjectIntProcedure<? super T>> void forEachWithIndex(
    Iterable<T> iterable,
    ObjectIntProcedureFactory<BT> procedureFactory,
    Combiner<BT> combiner,
    Executor executor)
{
  int taskCount = Math.max(
      ParallelIterate.DEFAULT_PARALLEL_TASK_COUNT,
      Iterate.sizeOf(iterable) / ParallelIterate.DEFAULT_MIN_FORK_SIZE);
  ParallelIterate.forEachWithIndex(
      iterable,
      procedureFactory,
      combiner,
      ParallelIterate.DEFAULT_MIN_FORK_SIZE,
      taskCount,
      executor);
}
origin: goldmansachs/gs-collections

private static <T> int calculateTaskCount(Iterable<T> iterable, int batchSize)
{
  if (iterable instanceof BatchIterable<?>)
  {
    return FJIterate.calculateTaskCount((BatchIterable<?>) iterable, batchSize);
  }
  return FJIterate.calculateTaskCount(Iterate.sizeOf(iterable), batchSize);
}
origin: goldmansachs/gs-collections

public static <E> ArrayAdapter<E> newArrayWithItem(Iterable<? extends E> iterable, E itemToAdd)
{
  int oldSize = Iterate.sizeOf(iterable);
  E[] array = (E[]) new Object[oldSize + 1];
  Iterate.toArray(iterable, array);
  array[oldSize] = itemToAdd;
  return new ArrayAdapter<E>(array);
}
origin: goldmansachs/gs-collections

private static <T> int calculateTaskCount(Iterable<T> iterable, int batchSize)
{
  if (iterable instanceof BatchIterable<?>)
  {
    return ParallelIterate.calculateTaskCount((BatchIterable<?>) iterable, batchSize);
  }
  return ParallelIterate.calculateTaskCount(Iterate.sizeOf(iterable), batchSize);
}
origin: goldmansachs/gs-collections

public static <T, PT extends ObjectIntProcedure<? super T>> void forEachWithIndex(
    Iterable<T> iterable,
    ObjectIntProcedureFactory<PT> procedureFactory,
    Combiner<PT> combiner,
    ForkJoinPool executor)
{
  int taskCount = Math.max(
      FJIterate.DEFAULT_PARALLEL_TASK_COUNT,
      Iterate.sizeOf(iterable) / DEFAULT_MIN_FORK_SIZE);
  FJIterate.forEachWithIndex(iterable, procedureFactory, combiner, DEFAULT_MIN_FORK_SIZE, taskCount, executor);
}
origin: goldmansachs/gs-collections

public ImmutableList<T> newWithAll(Iterable<? extends T> elements)
{
  final int oldSize = this.size();
  int newSize = Iterate.sizeOf(elements);
  final T[] array = (T[]) new Object[oldSize + newSize];
  this.toArray(array);
  Iterate.forEachWithIndex(elements, new ObjectIntProcedure<T>()
  {
    public void value(T each, int index)
    {
      array[oldSize + index] = each;
    }
  });
  return Lists.immutable.with(array);
}
origin: goldmansachs/gs-collections

private boolean retainAllFromNonSet(Iterable<?> iterable)
{
  int retainedSize = Iterate.sizeOf(iterable);
  UnifiedSetWithHashingStrategy<T> retainedCopy = new UnifiedSetWithHashingStrategy<T>(this.hashingStrategy, retainedSize, this.loadFactor);
  for (Object key : iterable)
  {
    this.addIfFound((T) key, retainedCopy);
  }
  if (retainedCopy.size() < this.size())
  {
    this.maxSize = retainedCopy.maxSize;
    this.occupied = retainedCopy.occupied;
    this.table = retainedCopy.table;
    return true;
  }
  return false;
}
origin: goldmansachs/gs-collections

private boolean retainAllFromNonSet(Iterable<?> iterable)
{
  int retainedSize = Iterate.sizeOf(iterable);
  UnifiedSet<T> retainedCopy = new UnifiedSet<T>(retainedSize, this.loadFactor);
  for (Object key : iterable)
  {
    this.addIfFound((T) key, retainedCopy);
  }
  if (retainedCopy.size() < this.size())
  {
    this.maxSize = retainedCopy.maxSize;
    this.occupied = retainedCopy.occupied;
    this.table = retainedCopy.table;
    return true;
  }
  return false;
}
origin: goldmansachs/gs-collections

public boolean addAllIterable(Iterable<? extends T> iterable)
{
  if (iterable instanceof UnifiedSetWithHashingStrategy)
  {
    return this.copySet((UnifiedSetWithHashingStrategy<?>) iterable);
  }
  int size = Iterate.sizeOf(iterable);
  this.ensureCapacity(size);
  int oldSize = this.size();
  Iterate.forEachWith(iterable, Procedures2.<T>addToCollection(), this);
  return this.size() != oldSize;
}
origin: goldmansachs/gs-collections

public static <T, V, R extends Collection<V>> R flatCollect(
    Iterable<T> iterable,
    Function<? super T, ? extends Iterable<V>> function,
    R target,
    int batchSize,
    ForkJoinPool executor,
    boolean allowReorderedResult)
{
  int size = Iterate.sizeOf(iterable);
  int taskSize = size / FJIterate.DEFAULT_PARALLEL_TASK_COUNT;
  FlatCollectProcedureCombiner<T, V> combiner =
      new FlatCollectProcedureCombiner<>(iterable, target, size, allowReorderedResult);
  FlatCollectProcedureFactory<T, V> procedureFactory = new FlatCollectProcedureFactory<>(function, taskSize);
  int taskCount = FJIterate.calculateTaskCount(size, batchSize);
  FJIterate.forEach(iterable, procedureFactory, combiner, batchSize, taskCount, executor);
  return (R) combiner.getResult();
}
origin: goldmansachs/gs-collections

public static <T, V, R extends Collection<V>> R collect(
    Iterable<T> iterable,
    Function<? super T, V> function,
    R target,
    int batchSize,
    ForkJoinPool executor,
    boolean allowReorderedResult)
{
  int size = Iterate.sizeOf(iterable);
  FastListCollectProcedureCombiner<T, V> combiner = new FastListCollectProcedureCombiner<>(iterable, target, size, allowReorderedResult);
  int taskCount = FJIterate.calculateTaskCount(size, batchSize);
  FastListCollectProcedureFactory<T, V> procedureFactory = new FastListCollectProcedureFactory<>(function, size / taskCount);
  FJIterate.forEach(
      iterable,
      procedureFactory,
      combiner,
      batchSize,
      taskCount,
      executor);
  return (R) combiner.getResult();
}
origin: goldmansachs/gs-collections

public static <T, V, R extends Collection<V>> R collect(
    Iterable<T> iterable,
    Function<? super T, V> function,
    R target,
    int batchSize,
    Executor executor,
    boolean allowReorderedResult)
{
  int size = Iterate.sizeOf(iterable);
  FastListCollectProcedureCombiner<T, V> combiner = new FastListCollectProcedureCombiner<T, V>(iterable, target, size, allowReorderedResult);
  int taskCount = ParallelIterate.calculateTaskCount(iterable, batchSize);
  FastListCollectProcedureFactory<T, V> procedureFactory = new FastListCollectProcedureFactory<T, V>(function, size / taskCount);
  ParallelIterate.forEach(
      iterable,
      procedureFactory,
      combiner,
      batchSize,
      taskCount,
      executor);
  return (R) combiner.getResult();
}
origin: goldmansachs/gs-collections

public boolean addAllIterable(Iterable<? extends T> iterable)
{
  if (iterable instanceof UnifiedSet)
  {
    return this.copySet((UnifiedSet<?>) iterable);
  }
  int size = Iterate.sizeOf(iterable);
  this.ensureCapacity(size);
  int oldSize = this.size();
  if (iterable instanceof List && iterable instanceof RandomAccess)
  {
    List<T> list = (List<T>) iterable;
    for (int i = 0; i < size; i++)
    {
      this.add(list.get(i));
    }
  }
  else
  {
    Iterate.forEachWith(iterable, Procedures2.<T>addToCollection(), this);
  }
  return this.size() != oldSize;
}
origin: goldmansachs/gs-collections

/**
 * Assert that the given {@link Iterable} is <em>not</em> empty.
 */
public static void assertNotEmpty(String iterableName, Iterable<?> actualIterable)
{
  try
  {
    Verify.assertObjectNotNull(iterableName, actualIterable);
    Assert.assertFalse(iterableName + " should be non-empty, but was empty", Iterate.isEmpty(actualIterable));
    Assert.assertTrue(iterableName + " should be non-empty, but was empty", Iterate.notEmpty(actualIterable));
    Assert.assertNotEquals(iterableName + " should be non-empty, but was empty", 0, Iterate.sizeOf(actualIterable));
  }
  catch (AssertionError e)
  {
    Verify.throwMangledException(e);
  }
}
origin: goldmansachs/gs-collections

/**
 * Assert that the given {@link Iterable} is <em>not</em> empty.
 */
public static void assertIterableNotEmpty(String iterableName, Iterable<?> iterable)
{
  try
  {
    Verify.assertObjectNotNull(iterableName, iterable);
    Assert.assertFalse(iterableName + " should be non-empty, but was empty", Iterate.isEmpty(iterable));
    Assert.assertTrue(iterableName + " should be non-empty, but was empty", Iterate.notEmpty(iterable));
    Assert.assertNotEquals(iterableName + " should be non-empty, but was empty", 0, Iterate.sizeOf(iterable));
  }
  catch (AssertionError e)
  {
    Verify.throwMangledException(e);
  }
}
origin: goldmansachs/gs-collections

  @Test
  @Override
  default void Iterable_remove()
  {
    Iterable<Integer> iterable = this.newWith(3, 3, 3, 2, 2, 1);
    Iterator<Integer> iterator = iterable.iterator();
    iterator.next();
    iterator.remove();
    assertEquals(this.allowsDuplicates() ? 5 : 2, Iterate.sizeOf(iterable));
    assertThat(
        iterable,
        isOneOf(
            this.newWith(3, 3, 3, 2, 2),
            this.newWith(3, 3, 3, 2, 1),
            this.newWith(3, 3, 2, 2, 1)));
  }
}
origin: goldmansachs/gs-collections

  @Override
  default void Iterable_remove()
  {
    MutableMap<Object, Integer> iterable = this.newWith(3, 3, 3, 2, 2, 1);
    Iterator<Integer> iterator = iterable.iterator();
    iterator.next();
    iterator.remove();
    assertEquals(this.allowsDuplicates() ? 5 : 2, Iterate.sizeOf(iterable));
    assertThat(iterable.toBag(), isOneOf(
        this.getExpectedFiltered(3, 3, 3, 2, 2),
        this.getExpectedFiltered(3, 3, 3, 2, 1),
        this.getExpectedFiltered(3, 3, 2, 2, 1)));
  }
}
com.gs.collections.impl.utilityIteratesizeOf

Javadoc

Returns the size of an iterable. In the case of Collections and RichIterables, the method size is called. All other iterables will force a complete iteration to happen, which can be unnecessarily costly.

Popular methods of Iterate

  • notEmpty
    A null-safe check on a collection to see if it is notEmpty. A null collection results in a false.
  • collect
    Same as the #collect(Iterable,Function) method with two parameters, except that the results are gath
  • contains
    Returns true if the iterable contains the value. In the case of Collections and RichIterables, the m
  • count
    Returns the total number of elements that evaluate to true for the specified predicate. Example usin
  • forEach
    The procedure is evaluated for each element of the iterable. Example using a Java 8 lambda expressio
  • forEachWithIndex
    Iterates over a collection passing each element and the current relative int index to the specified
  • isEmpty
    A null-safe check on a collection to see if it isEmpty. A null collection results in a true.
  • reject
    Same as the reject method with one parameter but uses the specified target collection for the result
  • select
    Same as the select method with two parameters but uses the specified target collection Example using
  • toArray
    Copies the specified iterable into the specified array.
  • addAllIterable
    Add all elements from the source Iterable to the target collection, returns true if any element was
  • addAllTo
    Add all elements from the source Iterable to the target collection, return the target collection.
  • addAllIterable,
  • addAllTo,
  • addToMap,
  • allSatisfy,
  • allSatisfyWith,
  • anySatisfy,
  • anySatisfyWith,
  • appendString,
  • collectBoolean

Popular in Java

  • Finding current android device location
  • setContentView (Activity)
  • setRequestProperty (URLConnection)
  • notifyDataSetChanged (ArrayAdapter)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • IOException (java.io)
    Signals that an I/O exception of some sort has occurred. This class is the general class of exceptio
  • SortedSet (java.util)
    A Set that further provides a total ordering on its elements. The elements are ordered using their C
  • StringTokenizer (java.util)
    The string tokenizer class allows an application to break a string into tokens. The tokenization met
  • Timer (java.util)
    A facility for threads to schedule tasks for future execution in a background thread. Tasks may be s
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now