Collection - Set

Venn Diagram

About

A set is:

The objects element of the set have the same type (the type may be a composed type such as a tuple)

The mathematical concept of a set is a group of unique items, meaning that the group contains no duplicates (theory) but many data application have extended this definition with a bag (multiset) (such as a table)

The set is used to perform distinct operation (ie deleting duplicates)

Examples

In Programming language

Some real-world examples of sets include the following:

  • The set of uppercase letters 'A' through 'Z'
  • The set of nonnegative integers {0, 1, 2 …}
  • The set of reserved Java programming language keywords {'import', 'class', 'public', 'protected'…}
  • A set of people (friends, employees, clients, …)
  • The set of records returned by a database query - See resulset (in java)
  • The set of Component objects in a Container
  • The set of all pairs
  • The empty set {}

In Computer Science

  • The idea of a “connection pool” is a set of open connections to a database server.
  • Web servers have to manage sets of clients and connections.
  • File descriptors provide another example of a set in the operating system.

Basic properties of sets

The basic properties of sets:

  • Sets contains only one instance of each item
  • Sets may be finite or infinite
  • Sets can define abstract concepts

Set expression

Set of Non-negative number

In Mathese, “the set of non-negative numbers” is written like this:

delim{lbrace}{ x in bbR : x>= 0}{rbrace}

where:

  • The colon stands for “such that”
  • the part before the colon specifies the elements of the set, and introduces a variable to be used in the second part
  • the part after the colon: defines a filter rule

The above notation can also be shortened if x is wel known :

delim{lbrace}{ x : x>= 0}{rbrace}

Another example

Another example where the set consists of

1/2

and

1/3delim{lbrace}{ x : x^2 - {5/6}x + {1/6} = 0}{rbrace}

Tuple

Tuples examples in set expression:

  • The set expression of all pairs of real numbers in which the second element of the pair is

the square of the first can be written:

delim{lbrace}{(x,y) in bbR x bbR : y = x^2 }{rbrace}

of abbreviated:

delim{lbrace}{(x,y) : y = x^2 }{rbrace}
  • The set expression of triples consisting of nonnegative real numbers.
delim{lbrace}{(x,y, z) in bbR x bbR x bbR: x >= 0, y >= 0, z >=0}{rbrace}

Documentation / Reference





Discover More
Data System Architecture
(Collection|Container) Data Type (Set, Bag, Sequence)

A collection is a abstract data type for grouping together multiple values. It's therefore sometime known as a container and creates a aggregation relationship A collection is: an object that groups...
Relational Data Model
(Relation|Table) - Tabular data

A Relation is a logical data structure composed of tuple (row) attribute (column, field) The following data structure are a relation: a table, a materialized view (query) (store data) a query,...
Data System Architecture
(Relation|Table) - Tabular data

This section is based on the relation data structure must well known under the term of table. The system that manages this structure are called Relational databases (or RDMS) . They are founded on Set...
Word Recognition Automaton
Automata - Finite Automata

A finite automaton is an automaton that has a set of states and its control moves from state to state in response to external inputs. It has a start and an end state and there are only a finite number...
Data System Architecture
Collection - (Tuple|Vector|Row)

A tuple is: a finite list of elements (fields) - It can only contain a specific number of elements. ordered by position that may have different types. and still be completely typesafe. You can...
Data System Architecture
Collection - Map (Associative arrays|Dictionary)

A map is an object that maps keys to values (known as property) Also known as: associative memories” or “associative arrays” dictionary hash table A map cannot contain duplicate keys; each...
Venn Diagram
Collection - MultiSet (bag or mset)

A multiset (aka bag or mset) is a set with one big difference because it allows for multiple instances of each of its elements (ie duplicate are allowed) This is the same structure that would support...
Data System Architecture
Collection - Sequence (Ordered)

A sequence is an abstract collection: of non-unique element where order matters - ie (A,B) is not equal to (B,A) non-unique means that it allows duplicate member (the same element/value may occur...
Java Conceptuel Diagram
Java - Set (Collection)

This interface is a member of the Java Collections Framework. Set is a collection that cannot contain duplicate elements. This interface models the mathematical set abstraction and is used to represent...
Javascript - Set

The Set interface represents a set data type and works only with primitive type as there is no way to define an object equality function. object Jsdoc Declaration Add/Delete Size Contains...



Share this page:
Follow us:
Task Runner