11.8. Sets

Most of the straightforward kinds of collections storage can be done in lists. The Set is a kind of expansion of List that allows you greater control over the elements contained in it. A Set is a List that does not allow duplicate elements. Because ColdFusion has no precisely corresponding storage mechanism, you might think of this as a primary key in a relational database table—it is just a uniqueness constraint.

The Set classes include: SortedSet, TreeSet, and HashSet, which we will discuss here in turn. Any Set implements these methods, among others:

  • add() adds an element to the set. Returns boolean regarding success of the operation. Returns false if an attempt is made to add a duplicate element to the set.

  • contains(Object o) returns ...

Get Java™ for ColdFusion® Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.