版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/everlasting_188/article/details/86662499
1、并发类
BlockingQueue
defines a first-in-first-out data structure that blocks or times out when you attempt to add to a full queue, or retrieve from an empty queue.
阻塞队列,线程池使用到了
ConcurrentMap
is a subinterface ofjava.util.Map
that defines useful atomic operations. These operations remove or replace a key-value pair only if the key is present, or add a key-value pair only if the key is absent. Making these operations atomic helps avoid synchronization. The standard general-purpose implementation ofConcurrentMap
isConcurrentHashMap
, which is a concurrent analog ofHashMap
.
HashMap的并发实现ConcurrentHashMap
,
ConcurrentNavigableMap
is a subinterface ofConcurrentMap
that supports approximate matches. The standard general-purpose implementation ofConcurrentNavigableMap
isConcurrentSkipListMap
, which is a concurrent analog ofTreeMap
.
TreeMap的并发实现ConcurrentSkipListMap
,
2、集合的算法部分
Collections
class provides five algorithms for doing routine data manipulation on List
objects, all of which are pretty straightforward:
reverse
— reverses the order of the elements in aList
.fill
— overwrites every element in aList
with the specified value. This operation is useful for reinitializing aList
.copy
— takes two arguments, a destinationList
and a sourceList
, and copies the elements of the source into the destination, overwriting its contents. The destinationList
must be at least as long as the source. If it is longer, the remaining elements in the destinationList
are unaffected.swap
— swaps the elements at the specified positions in aList
.addAll
— adds all the specified elements to aCollection
. The elements to be added may be specified individually or as an array.
集合提供了针对list的操作,包括reverse、fill、copy、swap和addAll方法
Collections.binarySearch(list, key);
集合类的二分查找
3、集合的聚合操作
roster .stream() .forEach(e -> System.out.println(e.getName());
double average = roster .stream() .filter(p -> p.getGender() == Person.Sex.MALE) .mapToInt(Person::getAge) .average() .getAsDouble();
待续