CSC 216 Lecture 12: CSC216 - Array Based Lists

59 views5 pages
29 Sep 2016
School
Course
Professor

Document Summary

Data structures: structures that store elements in a manner that makes it easy for a client to work with the elements. Special collections are specialized for particular types of operations : ordering, duplicates, adding/removing items, common sets of operations: add, remove, get, contains, size. List: an ordered collection of elements: accessible by a zero-based index, size = number of elements in the list, elements can be added to an empty list, @ the front, @ middle, and @ back. Adding an element to the end of the list: list[?] Getting an element from an index: int v = list[3]; Here"s a scenario suppose we have a file of integers that represent grades, counts, etc. Working with arraylist: construction: arraylist list = new. Arraylist(): adding an element to the end of the list: list. add(42), adding an element at an index: list. add(3, 42); //index, element, removing an element: list. remove(3); //index, getting an element: list. get(3); //index.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents