Collectors Clase
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Implementaciones de Collector que implementan diversas operaciones de reducción útiles, como acumular elementos en colecciones, resumir elementos según diversos criterios, etc.
[Android.Runtime.Register("java/util/stream/Collectors", ApiSince=24, DoNotGenerateAcw=true)]
public sealed class Collectors : Java.Lang.Object
[<Android.Runtime.Register("java/util/stream/Collectors", ApiSince=24, DoNotGenerateAcw=true)>]
type Collectors = class
inherit Object
- Herencia
- Atributos
Comentarios
Implementaciones de Collector que implementan diversas operaciones de reducción útiles, como acumular elementos en colecciones, resumir elementos según diversos criterios, etc.
A continuación se muestran ejemplos de uso de los recopiladores predefinidos para realizar tareas comunes de reducción mutable:
{@code
// Accumulate names into a List
List<String> list = people.stream()
.map(Person::getName)
.collect(Collectors.toList());
// Accumulate names into a TreeSet
Set<String> set = people.stream()
.map(Person::getName)
.collect(Collectors.toCollection(TreeSet::new));
// Convert elements to strings and concatenate them, separated by commas
String joined = things.stream()
.map(Object::toString)
.collect(Collectors.joining(", "));
// Compute sum of salaries of employee
int total = employees.stream()
.collect(Collectors.summingInt(Employee::getSalary));
// Group employees by department
Map<Department, List<Employee>> byDept = employees.stream()
.collect(Collectors.groupingBy(Employee::getDepartment));
// Compute sum of salaries by department
Map<Department, Integer> totalByDept = employees.stream()
.collect(Collectors.groupingBy(Employee::getDepartment,
Collectors.summingInt(Employee::getSalary)));
// Partition students into passing and failing
Map<Boolean, List<Student>> passingFailing = students.stream()
.collect(Collectors.partitioningBy(s -> s.getGrade() >= PASS_THRESHOLD));
}
Agregado en la versión 1.8.
Java documentación para java.util.stream.Collectors.
Las partes de esta página son modificaciones basadas en el trabajo creado y compartido por el Android y se usan según los términos descritos en creative Creative Commons 2.5 Attribution License.
Propiedades
| Nombre | Description |
|---|---|
| Class |
Devuelve la clase en tiempo de ejecución de este |
| Handle |
Identificador de la instancia de Android subyacente. (Heredado de Object) |
| JniIdentityHashCode |
Obtiene el código hash de identidad asignado a este Java del mismo nivel por el tiempo de ejecución de interoperabilidad. (Heredado de Object) |
| JniManagedPeerState |
Implementaciones de |
| JniPeerMembers |
Obtiene los metadatos de JNI usados para invocar miembros de este Java del mismo nivel. |
| PeerReference |
Obtiene la referencia de objeto JNI para este Java del mismo nivel. (Heredado de Object) |
| ThresholdClass |
Esta API admite la infraestructura mono para Android y no está pensada para usarse directamente desde el código. (Heredado de Object) |
| ThresholdType |
Esta API admite la infraestructura mono para Android y no está pensada para usarse directamente desde el código. (Heredado de Object) |
Métodos
| Nombre | Description |
|---|---|
| AveragingDouble(IToDoubleFunction) |
Devuelve un |
| AveragingInt(IToIntFunction) |
Devuelve un |
| AveragingLong(IToLongFunction) |
Devuelve un |
| Clone() |
Crea y devuelve una copia de este objeto. (Heredado de Object) |
| CollectingAndThen(ICollector, IFunction) |
|
| Construct(JniObjectReference, JniObjectReferenceOptions) |
Implementaciones de |
| Counting() |
Devuelve un |
| Dispose() |
Libera los recursos mantenidos por este Java del mismo nivel. (Heredado de Object) |
| Dispose(Boolean) |
Libera los recursos mantenidos por este Java del mismo nivel. (Heredado de Object) |
| DisposeUnlessReferenced() |
Implementaciones de |
| Equals(Object) |
Implementaciones de |
| Equals(Object) |
Indica si algún otro objeto es "igual a" este. (Heredado de Object) |
| Filtering(IPredicate, ICollector) |
Adapta un |
| GetHashCode() |
Devuelve un valor de código hash para el objeto . (Heredado de Object) |
| GroupingBy(IFunction, ICollector) |
Devuelve una |
| GroupingBy(IFunction, ISupplier, ICollector) |
Devuelve una |
| GroupingBy(IFunction) |
Devuelve una |
| GroupingByConcurrent(IFunction, ICollector) |
Devuelve una |
| GroupingByConcurrent(IFunction, ISupplier, ICollector) |
Devuelve una |
| GroupingByConcurrent(IFunction) |
Devuelve una operación simultánea |
| JavaFinalize() |
Lo llama el recolector de elementos no utilizados en un objeto cuando la recolección de elementos no utilizados determina que no hay más referencias al objeto . (Heredado de Object) |
| Joining() |
Devuelve un |
| Joining(ICharSequence, ICharSequence, ICharSequence) |
Devuelve un |
| Joining(ICharSequence) |
Devuelve un |
| Joining(String, String, String) |
Devuelve un |
| Joining(String) |
Devuelve un |
| Mapping(IFunction, ICollector) |
Adapta un |
| MaxBy(IComparator) |
Devuelve un |
| MinBy(IComparator) |
Devuelve un |
| Notify() |
Activa un único subproceso que está esperando en el monitor de este objeto. (Heredado de Object) |
| NotifyAll() |
Activa todos los subprocesos que están esperando en el monitor de este objeto. (Heredado de Object) |
| PartitioningBy(IPredicate, ICollector) |
Devuelve un |
| PartitioningBy(IPredicate) |
Devuelve un |
| Reducing(IBinaryOperator) |
Devuelve un objeto |
| Reducing(Object, IBinaryOperator) |
Devuelve un objeto |
| Reducing(Object, IFunction, IBinaryOperator) |
Devuelve un |
| SetHandle(IntPtr, JniHandleOwnership) |
Establece la propiedad Handle. (Heredado de Object) |
| SetPeerReference(JniObjectReference, JniObjectReferenceOptions) |
Implementaciones de |
| SummarizingDouble(IToDoubleFunction) |
Devuelve un objeto |
| SummarizingInt(IToIntFunction) |
Devuelve un objeto |
| SummarizingLong(IToLongFunction) |
Devuelve un objeto |
| SummingDouble(IToDoubleFunction) |
Devuelve un |
| SummingInt(IToIntFunction) |
Devuelve un |
| SummingLong(IToLongFunction) |
Devuelve un |
| Teeing(ICollector, ICollector, IBiFunction) |
Devuelve un objeto |
| ToArray<T>() |
Crea una matriz administrada a partir de este contenedor de matriz Java. (Heredado de Object) |
| ToCollection(ISupplier) |
Devuelve un |
| ToConcurrentMap(IFunction, IFunction, IBinaryOperator, ISupplier) |
Devuelve un elemento simultáneo |
| ToConcurrentMap(IFunction, IFunction, IBinaryOperator) |
Devuelve un elemento simultáneo |
| ToConcurrentMap(IFunction, IFunction) |
Devuelve un elemento simultáneo |
| ToList() |
Devuelve un |
| ToMap(IFunction, IFunction, IBinaryOperator, ISupplier) |
Devuelve un |
| ToMap(IFunction, IFunction, IBinaryOperator) |
Devuelve un |
| ToMap(IFunction, IFunction) |
Devuelve un |
| ToSet() |
Devuelve un |
| ToString() |
Devuelve una representación de cadena del objeto . (Heredado de Object) |
| ToUnmodifiableList() |
Devuelve un |
| ToUnmodifiableMap(IFunction, IFunction, IBinaryOperator) |
Devuelve un |
| ToUnmodifiableMap(IFunction, IFunction) |
Devuelve un |
| ToUnmodifiableSet() |
Devuelve un |
| UnregisterFromRuntime() |
Anula el registro de este Java del mismo nivel del tiempo de ejecución de interoperabilidad. (Heredado de Object) |
| Wait() |
Hace que el subproceso actual espere hasta que se despierte, normalmente por ser em notificado/em< o >em<interrumpido>/em<.><> (Heredado de Object) |
| Wait(Int64, Int32) |
Hace que el subproceso actual espere hasta que se despierte, normalmente por ser <em>notificado</em> o <em>interrumpido</em>, o hasta que haya transcurrido una cierta cantidad de tiempo real. (Heredado de Object) |
| Wait(Int64) |
Hace que el subproceso actual espere hasta que se despierte, normalmente por ser <em>notificado</em> o <em>interrumpido</em>, o hasta que haya transcurrido una cierta cantidad de tiempo real. (Heredado de Object) |
Implementaciones de interfaz explícitas
| Nombre | Description |
|---|---|
| IJavaPeerable.Disposed() |
Implementaciones de |
| IJavaPeerable.Finalized() |
Implementaciones de |
| IJavaPeerable.JniObjectReferenceControlBlock |
Implementaciones de |
| IJavaPeerable.SetJniIdentityHashCode(Int32) |
Implementaciones de |
| IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) |
Implementaciones de |
| IJavaPeerable.SetPeerReference(JniObjectReference) |
Implementaciones de |
Métodos de extensión
| Nombre | Description |
|---|---|
| GetJniTypeName(IJavaPeerable) |
Obtiene el nombre JNI del tipo de la instancia |
| JavaAs<TResult>(IJavaPeerable) |
Intente coerción |
| JavaCast<TResult>(IJavaObject) |
Realiza una conversión de tipos comprobados en tiempo de ejecución de Android. |
| JavaCast<TResult>(IJavaObject) |
Implementaciones de |
| TryJavaCast<TResult>(IJavaPeerable, TResult) |
Intente coerción |