CSC 216 Lecture 12: CSC216 - Array Based Lists
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.