Data Structures Set by using Java

Assoc. Prof. Leon Abdillah

Data Structures Set by using Java

Leon Andretti Abdillah

Data structures set consists of some non-duplicate elements. Set do not allow the same data. Set was implemented in to three sub data structures: 1) HashSet, 2) TreeSet, and 3) LinkedHashSet.

HashSet working with these methods:

Operations Notes
add() Adds the specified element to this set if it is not already present.
clear() Removes all of the elements from this set.
contains() Returns true if this set contains the specified element.
isEmpty() Returns true if this set contains no elements.
remove() Removes the specified element from this set if it is present.
removeAll() Removes from this set all of its elements that are contained in the specified collection (optional operation).
size() Returns the number of elements in this set (its cardinality).

References

Abdillah, L. A. (2013). Algorithms & Programming. Available: http://blog.binadarma.ac.id/mleonaa/teaching/programming/algorithm-and-programming-2/

Abdillah, L. A. (2014). Data Structures & Algorithms. Computer Science for Education, from http://blog.binadarma.ac.id/mleonaa/teaching/programming/data-structures/

Oracle Docs. The Set Interface. The Java Tutorials, from http://docs.oracle.com/javase/tutorial/collections/interfaces/set.html

Leave a Reply

Your email address will not be published. Required fields are marked *