org.eclipse.collections.api.stack.ImmutableStack Maven / Gradle / Ivy
/*
* Copyright (c) 2017 Goldman Sachs and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompany this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*/
package org.eclipse.collections.api.stack;
import org.eclipse.collections.api.bag.ImmutableBag;
import org.eclipse.collections.api.block.function.Function;
import org.eclipse.collections.api.block.function.Function0;
import org.eclipse.collections.api.block.function.Function2;
import org.eclipse.collections.api.block.function.primitive.BooleanFunction;
import org.eclipse.collections.api.block.function.primitive.ByteFunction;
import org.eclipse.collections.api.block.function.primitive.CharFunction;
import org.eclipse.collections.api.block.function.primitive.DoubleFunction;
import org.eclipse.collections.api.block.function.primitive.FloatFunction;
import org.eclipse.collections.api.block.function.primitive.IntFunction;
import org.eclipse.collections.api.block.function.primitive.LongFunction;
import org.eclipse.collections.api.block.function.primitive.ObjectIntToObjectFunction;
import org.eclipse.collections.api.block.function.primitive.ShortFunction;
import org.eclipse.collections.api.block.predicate.Predicate;
import org.eclipse.collections.api.block.predicate.Predicate2;
import org.eclipse.collections.api.block.procedure.Procedure;
import org.eclipse.collections.api.block.procedure.Procedure2;
import org.eclipse.collections.api.map.ImmutableMap;
import org.eclipse.collections.api.map.primitive.ImmutableObjectDoubleMap;
import org.eclipse.collections.api.map.primitive.ImmutableObjectLongMap;
import org.eclipse.collections.api.multimap.list.ImmutableListMultimap;
import org.eclipse.collections.api.partition.stack.PartitionImmutableStack;
import org.eclipse.collections.api.stack.primitive.ImmutableBooleanStack;
import org.eclipse.collections.api.stack.primitive.ImmutableByteStack;
import org.eclipse.collections.api.stack.primitive.ImmutableCharStack;
import org.eclipse.collections.api.stack.primitive.ImmutableDoubleStack;
import org.eclipse.collections.api.stack.primitive.ImmutableFloatStack;
import org.eclipse.collections.api.stack.primitive.ImmutableIntStack;
import org.eclipse.collections.api.stack.primitive.ImmutableLongStack;
import org.eclipse.collections.api.stack.primitive.ImmutableShortStack;
import org.eclipse.collections.api.tuple.Pair;
public interface ImmutableStack extends StackIterable
{
ImmutableStack push(T item);
ImmutableStack pop();
ImmutableStack pop(int count);
@Override
ImmutableStack takeWhile(Predicate predicate);
@Override
ImmutableStack dropWhile(Predicate predicate);
@Override
PartitionImmutableStack partitionWhile(Predicate predicate);
@Override
ImmutableStack distinct();
@Override
ImmutableStack tap(Procedure procedure);
@Override
ImmutableStack select(Predicate predicate);
@Override
ImmutableStack selectWith(Predicate2 predicate, P parameter);
@Override
ImmutableStack reject(Predicate predicate);
@Override
ImmutableStack rejectWith(Predicate2 predicate, P parameter);
@Override
ImmutableStack selectInstancesOf(Class clazz);
@Override
PartitionImmutableStack partition(Predicate predicate);
@Override
PartitionImmutableStack partitionWith(Predicate2 predicate, P parameter);
@Override
ImmutableStack collect(Function function);
@Override
ImmutableBooleanStack collectBoolean(BooleanFunction booleanFunction);
@Override
ImmutableByteStack collectByte(ByteFunction byteFunction);
@Override
ImmutableCharStack collectChar(CharFunction charFunction);
@Override
ImmutableDoubleStack collectDouble(DoubleFunction doubleFunction);
@Override
ImmutableFloatStack collectFloat(FloatFunction floatFunction);
@Override
ImmutableIntStack collectInt(IntFunction intFunction);
@Override
ImmutableLongStack collectLong(LongFunction longFunction);
@Override
ImmutableShortStack collectShort(ShortFunction shortFunction);
@Override
ImmutableStack collectWith(Function2 function, P parameter);
@Override
ImmutableStack collectIf(Predicate predicate, Function function);
/**
* @since 9.1.
*/
@Override
default ImmutableStack collectWithIndex(ObjectIntToObjectFunction function)
{
int[] index = {0};
return this.collect(each -> function.valueOf(each, index[0]++));
}
@Override
ImmutableStack flatCollect(Function> function);
/**
* @since 9.2
*/
@Override
default ImmutableStack flatCollectWith(Function2> function, P parameter)
{
return this.flatCollect(each -> function.apply(each, parameter));
}
@Override
ImmutableListMultimap groupBy(Function function);
/**
* @since 9.0
*/
@Override
default ImmutableBag countBy(Function function)
{
return this.asLazy().collect(function).toBag().toImmutable();
}
/**
* @since 9.0
*/
@Override
default ImmutableBag countByWith(Function2 function, P parameter)
{
return this.asLazy().collectWith(function, parameter).toBag().toImmutable();
}
/**
* @since 10.0.0
*/
@Override
default ImmutableBag countByEach(Function> function)
{
return this.asLazy().flatCollect(function).toBag().toImmutable();
}
@Override
ImmutableListMultimap groupByEach(Function> function);
@Override
ImmutableMap groupByUniqueKey(Function function);
@Override
ImmutableStack> zip(Iterable that);
@Override
ImmutableStack> zipWithIndex();
@Override
ImmutableMap aggregateInPlaceBy(Function groupBy, Function0 zeroValueFactory, Procedure2 mutatingAggregator);
@Override
ImmutableMap aggregateBy(Function groupBy, Function0 zeroValueFactory, Function2 nonMutatingAggregator);
@Override
ImmutableObjectLongMap sumByInt(Function groupBy, IntFunction function);
@Override
ImmutableObjectDoubleMap sumByFloat(Function groupBy, FloatFunction function);
@Override
ImmutableObjectLongMap sumByLong(Function groupBy, LongFunction function);
@Override
ImmutableObjectDoubleMap sumByDouble(Function groupBy, DoubleFunction function);
/**
* Size takes linear time on ImmutableStacks.
*/
@Override
int size();
}