Set

The Set


a test This is a test this This is

The Set represents a unique set of items... for example:

  • The Letters of the Alphabet
  • The Numbers in a numbering system
  • List of available Colors

Set differs from a List in that the items or entities in a Set are unique with no ambiguity. Therefore, a set can not contain duplicates... well... not in the strictest sense. Lets look closer...

Let us add this string to a set. "This is a test" adding each word seperately.

If we print the set it will look like this:





Now add the word this again and the output will look like this:






That means the list is case sensitive and sees this and This as two different words. That makes sense Java is case sensitive.

When we add the word in the original case This it never gets added because the Set rejects it.

CREATED 2020-10-02 07:26:15.0

010-00-03-47

UPDATED 2020-10-02 07:26:29.0

Implementations


- A thread safe Set that uses CopyOnWriteArrayList

These are the generic implementation of the Set interface: - a skip list or a linked list that acts like an ordered array.

    - provides the basics to implement the interface
  • AbstractSet
  • ConcurrentSkipListSet
  • CopyOnWriteArraySet
  • CREATED 2020-10-02 10:34:06.0

    010-00-03-4C

    UPDATED 2020-10-02 10:34:25.0

    AbstractSet


    The AbstractSet class is a mostly baked implementation of the Set interface.

    AbstractSet extends AbstractCollection which has a fair amount of the collection implementation already set up... but there is some work to do here...

    You will need to implement these methods:

    • size - Returns an int (the size of the collection)
    • iterator - Returns an iterator to iterate over the collection

    CREATED 2020-10-03 08:02:07.0

    010-00-03-4D

    UPDATED 2020-10-03 08:02:22.0

    Set JavaDoc
    L
    I
    N
    K
    S

    DBID: db.wam

    Page Server: Ruger

    ©2019 Leistware.com
          Hello anonymous