Top: Index Previous: IO Up: Java Programming Next: Regexp

CSC8311 -- Advanced Object-Orientated Programming

Collections

Bioinformatics is a data-rich domain. While there are some core, clever algorithms which are responsible for lots of the analysis, a large part of the what you will need involves getting data into an appropriate format, manipulating it, sorting it and generally transforming it in to something more useful than you started off with.

For all this, you need collections. This is a general computing science term. It's synonymous with container. In Java, it describes a Class 1 for grouping other together objects.

Computer Scientists get terrible excited about collections. A large part of the fundamental CS involves organising, storing and sorting collections. This means that descriptions tend to assume quite a lot of prior knowledge; if you get confused during this tutorial, remember to try Wikipedia or other Googlable web resources 2. I've added short definitions and an analogies below.

We will be following collections trail in the Java tutorial. Please read the entire tutorial and attempt the exercises.

Definitions

A Collection

A collection is a group of objects where we make no assumptions at all about relationships between the objects.

A Set

A Set is a group of objects, much like a collection except there can't be any duplicates. A group of people waiting at a train platform before the train arrives would be a set; each person only occurs once (since you can't duplicate people) and there's no order between them 3.

A List

A List is a group of objects, except that there can be duplications, the elements are ordered and you can get to each one. The train when it pulls up, is an example; the carriages have an order. You can get to carriage C, for example, without going near carriage A or B. For a real train, isn't possible to have duplicates of course 4.

A queue

Once the train arrives, everybody forms an orderly line or a queue 5. The queue has a front (and a back). People at the front (and only people at the front) can get out of the queue (ie onto the train). Others can only join the queue at the back. So, like a list, you have order, but you can only get to the people in the middle by looking at the front.

A Map

Once on the train, your ticket contains a seat and carriage number. This forms an index, which links a seat to the ticket. You can work out, from the start, which seat is which, you can go to your seat without, for example, having to look at all the other seats before it. It's a map or "hash". Other examples are: phone books, dictionaries or postal pidgeon holes.

Hopefully these definitions will help you as you read the collections trail.


1. Actually, a collection of Classes!

2. And be grateful that we are not doing trees or graphs. These get really, really complicated.

3. Well, relatively little. No metaphor is perfect.

4. No metaphor is perfect!

5. At least in Britain. The rest of the world form a data structure called a "heap".


Top: Index Previous: IO Up: Java Programming Next: Regexp