Programmazione Parametrica ( a k. a. Generics ) Introduzione ai meccanismi e concetti della programmazione parametrica


Containment testing (does the set contain a given object?)



Scaricare 1.39 Mb.
Pagina15/17
28.03.2019
Dimensione del file1.39 Mb.
1   ...   9   10   11   12   13   14   15   16   17

Containment testing (does the set contain a given object?)

  • Listing all elements (in arbitrary order)



  • Sets



    Sets

    • Standard Java library provides set implementations based on both data structures

      • HashSet
      • TreeSet
    • Both of these data structures implement the Set interface



    Set Classes and Interface in the Standard Library



    Iterator

    • Use an iterator to visit all elements in a set

    • A set iterator does not visit the elements in the order in which they were inserted

    • An element can not be added to a set at an iterator position

    • A set element can be removed at an iterator position



    Code for Creating and Using a Hash Set

    1   ...   9   10   11   12   13   14   15   16   17


    ©astratto.info 2019
    invia messaggio

        Pagina principale