Collection collection, Collection

Source: Internet
Author: User
Tags addall

Collection collection, Collection

 

For some internal collection algorithms, refer to the container summary in this article.

 

(Abstract +)

Collection

Subclass: List, Queue, Set

Add:

  • Add (E): boolean
  • AddAll (Collection <? Extends E>): boolean

Delete:

  • Remove (Object): boolean
  • RemoveAll (Collection <?>) : Boolean
  • RetainAll (Collection <?>) : Boolean
  • RemoveIf (Predicate <? Super E>): boolean
  • Clear ()

Query:

  • Contains (Object): boolean
  • ContainsAll (Collection <?>) : Boolean
  • Size (): int
  • IsEmpty (): boolean
  • ToArray (): Object []
  • ToArray (T []): T []
  • Collections. max (Collection <? Extends T>): T
  • Collections. max (Collection <? Extends T>, Comparator <? Super T>): T
    Maximum Value
  • Collections. min (Collection <? Extends T>): T
  • Collections. min (Collection <? Extends T>, Comparator <? Super T>): T
    Minimum value

Tools:

  • Iterator (): Iterator <E>
  • Spliterator (): Spliterator <E>
  • Stream (): Stream <E>
  • ParallelStream (): Stream <E>
  • Collections. unmodifiableCollection (Collection <? Extends T>): Collection <T>
    Read-only mode Packaging
  • Collections. synchronizedCollection (Collection <T>): Collection <T>
    Thread-Safe Packaging

 

(Abstract +)

(AbstractSequentia +)

List

Parent class: Collection

Subclass: ArrayList, struct list, Vector, Stack

Add:

  • Add (int, E)
  • AddAll (int, Collection <? Extends E>): boolean

Delete:

  • Remove (int): E

Change:

  • Set (int, E): E
  • ReplaceAll (UnaryOperator <E>)
  • Sort (Comparator <? Super E>)
  • Collections. swap (List <?>, Int, int)
    Swap two element locations

Query:

  • Get (int): E
  • IndexOf (Object): int
  • LastIndexOf (Object): int
  • SubList (int, int): List <E>
    Subset

Tools:

  • ListIterator (): ListIterator <E>
  • ListIterator (int): ListIterator <E>
  • Collections. unmodifiableList (List <? Extends T>): List <T>
    Read-only mode Packaging
  • Collections. synchronizedList (List <T>): List <T>
    Thread-Safe Packaging

 

ArrayList

Parent class: List, Collection

Change:

  • EnsureCapacity (int)
  • TrimToSize ()

 

Shortlist

Parent class: List, Deque, Queue, Connection

Feature: chained Storage

 

Vector

Parent class: List, Collection

Subclass: Stack

Features: thread security

Add:

  • AddElement (E)
  • InsertElementAt (E, int)

Delete:

  • RemoveAllElements ()
  • RemoveElement (Object): boolean
  • RemoveElementAt (int)

Change:

  • SetElementAt (E, int)
  • SetSize (int)
  • EnsureCapacity (int)
  • TrimToSize ()

Query:

  • FirstElement (): E
  • LastElement (): E
  • ElementAt (int): E
  • Elements (): Enumeration <E>
  • IndexOf (Object, int): int
  • LastIndexOf (Object, int): int
  • Capacity (): int
  • CopyInto (Object [])

 

Stack

Parent class: Vector, List, Collection

Features: thread security; inbound and outbound

Add:

  • Push (E): E

Delete:

  • Pop (): E

Change:

  • Peek (): E
  • Search (Object): int
  • Empty (): boolean

 

(Abstract +)

Queue

Parent class: Collection

Subclass: Deque, concurrentincluqueue, BlockingQueue, shortlist

Add:

  • Offer (E): boolean

Delete:

  • Poll (): E
  • Remove (): E

Query:

  • Peek (): E
  • Element (): E

 

Concurrent1_queue

Parent class: Queue, Collection

Features: chained storage; thread security; first-in-first-out

 

BlockingQueue

Parent class: Queue, Collection

Subclass: ArrayBlockingQueue, LinkedBlockingQueue, PriorityBlockingQueue, DelayQueue,

SynchronousQueue, TransferQueue, transfertransferqueue, BlockingDeque

Add:

  • Offer (E, long, TimeUnit): boolean
  • Put (E)

Delete:

  • Poll (long, TimeUnit): E
  • Take (): E
  • DrainTo (Collection <? Super E>): int
  • DrainTo (Collection <? Super E>, int): int

Query:

  • RemainingCapacity (): int

 

ArrayBlockingQueue

Parent class: BlockingQueue, Queue, Collection

Features: thread security; first-in-first-out; thread blocking when the team is full; thread blocking when the team is empty;

 

LinkedBlockingQueue

Parent class: BlockingQueue, Queue, Collection

Features: chained storage; thread security; first-in-first-out; blocking when the team is full; blocking when the team is empty;

 

PriorityBlockingQueue

Parent class: BlockingQueue, Queue, Collection

Features: thread security, rule sorting, and blocking of outbound threads when the team is empty;

Query:

  • Comparator (): Comparator <? Super E>

 

DelayQueue <E extends Delayed>

Parent class: BlockingQueue, Queue, Collection

Special certificate: thread security; rule sorting; when the team is empty or the team header is not expired, the queue thread is blocked;

 

SynchronousQueue

Parent class: BlockingQueue, Queue, Collection

Features: thread security; advanced post-exit; after an element enters the queue (put), the thread is blocked until the element leaves the queue; when the queue is empty, the thread is blocked;

 

TransferQueue

Parent class: BlockingQueue, Queue, Collection

Subclass: Required transferqueue

Add:

  • Transfer (E)
  • TryTransfer (E): boolean
  • TryTransfer (E, long, TimeUnit): boolean

Query:

  • GetWaitingConsumerCount (): int
  • HasWaitingConsumer (): boolean

 

LinkedTransferQueue

Parent class: TransferQueue, BlockingQueue, Queue, Collection

Features: thread security; first-in-first-out; after an element enters the queue (transfer), the thread in the queue is blocked until the element leaves the queue; when the queue is empty, the thread in the queue is blocked;

 

Deque

Parent class: Queue, Collection

Subclass: ArrayDeque, BlockingDeque, role list

Add:

  • AddFirst (E)
  • AddLast (E)
  • OfferFirst (E): boolean
  • OfferLast (E): boolean
  • Push (E): void

Delete:

  • RemoveFirst (): E
  • RemoveLast (): E
  • RemoveFirstOccurrence (Object): boolean
  • RemoveLastOccurrence (Object): boolean
  • PollFirst (): E
  • PollLast (): E
  • Pop (): E

Query:

  • GetFirst (): E
  • GetLast (): E
  • PeekFirst (): E
  • PeekLast (): E

Tools:

  • DescendingIterator (): Iterator <E>

 

ArrayDeque

Parent class: Deque, Queue, Collection

 

BlockingDeque

Parent class: Deque, BlockingQueue, Queue, Collection

Subclass: LinkedBlockingDeque

Add:

  • OfferFirst (E, long, TimeUnit): boolean
  • OfferLast (E, long, TimeUnit): boolean
  • PutFirst (E)
  • PutLast (E)

Delete:

  • PollFirst (long, TimeUnit): E
  • PollLast (long, TimeUnit): E
  • TakeFirst (): E
  • TakeLast (): E

 

LinkedBlockingDeque

Parent class: BlockingDeque, BlockingQueue, Deque, Queue, Collection

 

(Abstract +)

Set

Parent class: Collection

Subclass: HashSet, TreeSet, SortedSet, NavigableSet, EnumSet

Feature: representing non-Repeated sequences

Tools:

  • Collections. unmodifiableSet (Set <? Extends T>): Set <T>
    Read-only mode Packaging
  • Collections. synchronizedSet (Set <E>): Set <E>
    Thread-Safe Packaging

 

HashSet

Parent class: Set, Collection

Subclass: LinkedHashSet

Features: repeatable; Policy sorting (Hash Table Algorithm), generally unordered

 

LinkedHashSet

Parent class: HashSet, Set, Collection

Features: repeatable; retained in order

 

SortedSet

Parent class: Set, Collection

Subclass: TreeSet, NavigableSet

Feature: Indicates order

Query:

  • First (): E
  • Last (): E
  • HeadSet (E): SortedSet <E>
  • TailSet (E): SortedSet <E>
  • SubSet (E, E): SortedSet <E>
  • Comparator (): Comparator <? Super E>

Tools:

  • Collections. synchronizedSortedSet (SortedSet <T>): SortedSet <T>
    Thread-Safe Packaging
  • Collections. unmodifiableSortedSet (SortedSet <T>): SortedSet <T>
    Read-only mode Packaging

 

NavigableSet

Parent class: SortedSet, Set, Collection

Subclass: TreeSet

Features: Provides advanced operations

Delete:

  • PollFirst (): E
  • PollLast (): E

Query:

  • Ceiling (E): E
  • Floor (E): E
  • Higher (E): E
  • Lower (E): E
  • HeadSet (E, boolean): NavigableSet <E>
  • TailSet (E, boolean): NavigableSet <E>
  • SubSet (E, boolean, E, boolean): NavigableSet <E>
  • DescendingSet (): NavigableSet <E>

Tools:

  • DescendingIterator (): Iterator <E>
  • Collections. unmodifiableNavigableSet (NavigableSet <T>): NavigableSet <T>
    Read-only mode Packaging
  • Collections. synchronizedNavigableSet (NavigableSet <T>): NavigableSet <T>
    Thread-Safe Packaging

 

TreeSet

Parent class: NavigableSet, SortedSet, Set, Collection

Features: repeatable; Policy sorting (red-black tree algorithm); non-empty elements

 

EnumSet <E extends Enum <E>

Parent class: Set, Collection

Feature: used for Enumeration type

Build:

  • S + allOf (Class <E>): ElemSet <E>
    Full Set
  • S + noneOf (Class <E>): ElemSet <E>
    Empty set
  • S + copyOf (Collection <E>): ElemSet <E>
  • S + copyOf (EnumSet <E>): ElemSet <E>
  • S + complementOf (EnumSet <E>): ElemSet <E>
    Makeup
  • S + of (E...): ElemSet <E>
  • S + range (E, E): ElemSet <E>

 

To be updated!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.