Collectors 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
實作 Collector
可實作各種實用的縮減作業,例如將元素累積到集合、根據各種準則摘要元素等等。
[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
- 繼承
- 屬性
備註
實作 Collector
可實作各種實用的縮減作業,例如將元素累積到集合、根據各種準則摘要元素等等。
以下是使用預先定義的收集器來執行一般可變動縮減工作的範例:
{@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));
}
已在 1.8 中新增。
的 java.util.stream.Collectors
JAVA 檔。
此頁面的部分是根據所建立和共用的工作進行修改,並根據 2.5 屬性授權中所述的詞彙來使用。
屬性
Class |
傳回這個 |
Handle |
基礎 Android 實例的控制碼。 (繼承來源 Object) |
JniIdentityHashCode |
實作 |
JniPeerMembers |
實作 |
PeerReference |
實作 |
ThresholdClass |
此 API 支援適用于 Android 的 Mono 基礎結構,並不適合直接從您的程式碼使用。 (繼承來源 Object) |
ThresholdType |
此 API 支援適用于 Android 的 Mono 基礎結構,並不適合直接從您的程式碼使用。 (繼承來源 Object) |
方法
AveragingDouble(IToDoubleFunction) |
傳回 , |
AveragingInt(IToIntFunction) |
傳回 , |
AveragingLong(IToLongFunction) |
|
Clone() |
建立並傳回這個 物件的複本。 (繼承來源 Object) |
CollectingAndThen(ICollector, IFunction) |
|
Counting() |
|
Dispose() |
實作 |
Dispose(Boolean) |
實作 |
Equals(Object) |
指出其他物件是否「等於」這個物件。 (繼承來源 Object) |
Filtering(IPredicate, ICollector) |
|
GetHashCode() |
傳回此物件的雜湊碼值。 (繼承來源 Object) |
GroupingBy(IFunction) |
傳回在 |
GroupingBy(IFunction, ICollector) |
傳 |
GroupingBy(IFunction, ISupplier, ICollector) |
傳 |
GroupingByConcurrent(IFunction) |
傳回同時 |
GroupingByConcurrent(IFunction, ICollector) |
傳回同時 |
GroupingByConcurrent(IFunction, ISupplier, ICollector) |
傳回同時 |
JavaFinalize() |
當垃圾收集判斷物件不再參考物件時,垃圾收集行程會在物件上呼叫。 (繼承來源 Object) |
Joining() |
傳回 , |
Joining(ICharSequence) |
傳回 , |
Joining(ICharSequence, ICharSequence, ICharSequence) |
|
Joining(String) |
傳回 , |
Joining(String, String, String) |
|
Mapping(IFunction, ICollector) |
|
MaxBy(IComparator) |
傳回 , |
MinBy(IComparator) |
傳回 , |
Notify() |
喚醒正在等候此物件監視器的單一線程。 (繼承來源 Object) |
NotifyAll() |
喚醒正在等候此物件監視器的所有線程。 (繼承來源 Object) |
PartitioningBy(IPredicate) |
傳回 , |
PartitioningBy(IPredicate, ICollector) |
傳回 , |
Reducing(IBinaryOperator) |
傳回 , |
Reducing(Object, IBinaryOperator) |
傳回 , |
Reducing(Object, IFunction, IBinaryOperator) |
傳回 , |
SetHandle(IntPtr, JniHandleOwnership) |
設定 Handle 屬性。 (繼承來源 Object) |
SummarizingDouble(IToDoubleFunction) |
傳回 , |
SummarizingInt(IToIntFunction) |
傳回 , |
SummarizingLong(IToLongFunction) |
傳回 , |
SummingDouble(IToDoubleFunction) |
|
SummingInt(IToIntFunction) |
|
SummingLong(IToLongFunction) |
|
ToArray<T>() |
實作 |
ToCollection(ISupplier) |
傳回 , |
ToConcurrentMap(IFunction, IFunction) |
傳回同時 |
ToConcurrentMap(IFunction, IFunction, IBinaryOperator) |
傳回同時 |
ToConcurrentMap(IFunction, IFunction, IBinaryOperator, ISupplier) |
傳回同時 |
ToList() |
傳回 , |
ToMap(IFunction, IFunction) |
傳回 , |
ToMap(IFunction, IFunction, IBinaryOperator) |
傳回 , |
ToMap(IFunction, IFunction, IBinaryOperator, ISupplier) |
傳回 , |
ToSet() |
傳回 , |
ToString() |
傳回物件的字串表示。 (繼承來源 Object) |
ToUnmodifiableList() |
傳回 , |
ToUnmodifiableMap(IFunction, IFunction) |
傳回 , |
ToUnmodifiableMap(IFunction, IFunction, IBinaryOperator) |
傳回 , |
ToUnmodifiableSet() |
傳回 , |
UnregisterFromRuntime() |
實作 |
Wait() |
讓目前的執行緒等到喚醒為止,通常是 em < notified/em > 或 < em > interrupted < /em > 。 >< (繼承來源 Object) |
Wait(Int64) |
讓目前的執行緒等到喚醒為止,通常是 em < notified/em > 或 < em > interrupted < /em > ,或直到經過一定數量的即時為止。 <> (繼承來源 Object) |
Wait(Int64, Int32) |
讓目前的執行緒等到喚醒為止,通常是 em < notified/em > 或 < em > interrupted < /em > ,或直到經過一定數量的即時為止。 <> (繼承來源 Object) |
明確介面實作
IJavaPeerable.Disposed() |
實作 |
IJavaPeerable.DisposeUnlessReferenced() |
實作 |
IJavaPeerable.Finalized() |
實作 |
IJavaPeerable.JniManagedPeerState |
實作 |
IJavaPeerable.SetJniIdentityHashCode(Int32) |
實作 |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) |
實作 |
IJavaPeerable.SetPeerReference(JniObjectReference) |
實作 |
擴充方法
JavaCast<TResult>(IJavaObject) |
執行 Android 執行時間檢查的類型轉換。 |
JavaCast<TResult>(IJavaObject) |
實作 |
GetJniTypeName(IJavaPeerable) |
實作 |