Using a Java TreeSet

Covers the basic operations on a java TreeSet including creation, iteration, finding elements, etc.

The unexamined life is not worth living.
― Socrates

1. Introduction

A java Set is a Collection containing only unique elements. A TreeSet is an implementation of the Set which uses a Red-Black tree implementation. In this article, we demonstrate how to properly create and use a TreeSet.

Continue reading “Using a Java TreeSet”

An Introduction to Python Sets

Python supports sets which are a collection of unique elements and provide operations for computing set union, intersection and difference.

“The world is a book and those who do not travel read only one page.”
― Augustine of Hippo

1. Introduction

A set is a collection of unique elements. A common use is to eliminate duplicate elements from a list. In addition, it supports set operations like union intersection and difference.

Continue reading “An Introduction to Python Sets”

Java Collections – Set

A Set is a container which does not allow duplicate elements. Common Set implementations include HashSet, LinkedHashSet and TreeSet.

“Quotation, n: The act of repeating erroneously the words of another.”
― Ambrose Bierce, The Unabridged Devil’s Dictionary

Check out the earlier parts of this Java Collections Series: Introduction and Part 1.

1. Introduction

A Set is a container which does not contain duplicate elements. The item method equals() is used to determine whether the object is already present in the Set. At most one null element is allowed in the Set.

Continue reading “Java Collections – Set”