Collections: Difference between revisions
Mr. MacKenty (talk | contribs) (Created page with "right|frame|Programming basics<ref>http://www.flaticon.com/</ref> A collection — sometimes called a container — is simply an object that groups multip...") |
Mr. MacKenty (talk | contribs) No edit summary |
||
Line 3: | Line 3: | ||
A collection — sometimes called a container — is simply an object that groups multiple elements into a single unit. Collections are used to store, retrieve, manipulate, and communicate aggregate data. Typically, they represent data items that form a natural group, such as a poker hand (a collection of cards), a mail folder (a collection of letters), or a telephone directory (a mapping of names to phone numbers). If you have used the Java programming language — or just about any other programming language — you are already familiar with collections.<ref>https://docs.oracle.com/javase/tutorial/collections/intro/</ref> | A collection — sometimes called a container — is simply an object that groups multiple elements into a single unit. Collections are used to store, retrieve, manipulate, and communicate aggregate data. Typically, they represent data items that form a natural group, such as a poker hand (a collection of cards), a mail folder (a collection of letters), or a telephone directory (a mapping of names to phone numbers). If you have used the Java programming language — or just about any other programming language — you are already familiar with collections.<ref>https://docs.oracle.com/javase/tutorial/collections/intro/</ref> | ||
== Collection methods == | |||
'''Collection methods in Pseudocode are:'''<ref>http://ib.compscihub.net/wp-content/uploads/2015/04/4.3.10.pdf</ref> | |||
* .addItem( new data item ) | |||
* .resetNext( ) start at beginning of list | |||
* .hasNext( ) checks whether there are still more items in the list | |||
* .getNext( ) retrieve the next item in the list | |||
* .isEmpty( ) check whether the list is empty | |||
Write, in pseudocode, a collection that adds the first names of everyone in the class. You then must find the name of everyone whose name starts with M. | |||
== Do you understand this? == | |||
Revision as of 14:12, 8 October 2017
A collection — sometimes called a container — is simply an object that groups multiple elements into a single unit. Collections are used to store, retrieve, manipulate, and communicate aggregate data. Typically, they represent data items that form a natural group, such as a poker hand (a collection of cards), a mail folder (a collection of letters), or a telephone directory (a mapping of names to phone numbers). If you have used the Java programming language — or just about any other programming language — you are already familiar with collections.[2]
Collection methods[edit]
Collection methods in Pseudocode are:[3]
- .addItem( new data item )
- .resetNext( ) start at beginning of list
- .hasNext( ) checks whether there are still more items in the list
- .getNext( ) retrieve the next item in the list
- .isEmpty( ) check whether the list is empty
Write, in pseudocode, a collection that adds the first names of everyone in the class. You then must find the name of everyone whose name starts with M.
Do you understand this?[edit]
Standards[edit]
- Describe the characteristics and applications of a collection.
- Construct algorithms using the access methods of a collection.
- Discuss the need for sub-programmes and collections within programmed solutions.
- Construct algorithms using pre-defined sub-programmes, one-dimensional arrays and/or collections.