Data Structures and Object-Oriented Design VIII
Data Structures and
Object-Oriented Design
VIII
Spring 2014
Carola Wenk
Collections and Maps
?
The Collection interface is for storage and access, while a
Map interface is geared towards associating keys with objects.
Student database problem
Tulane¡¯s student database D stores n records:
record
ID
key
Operations on D:
¡°add¡±
Name
value ?D.put(key,value)
¡°find¡±
Address
Grades
?D.get(key)
?D.remove(key)
How should the data structure D be organized?
Direct-Access Table (array)
? Suppose every key is a different number: K ? {0, 1, ¡, m¨C1}
? Set up an array D[0 . . m¨C1] such that D[key] = value for every
record, and D[key]=null for keys without records.
D
...
00000006
000747111
John Welch
Jones
David Filo
Direct-Access Table (array)
class DirectAccessTable{
MyObject[] dataTable = null;
DirectAccessTable(int n){
dataTable = new MyObject[n];
for (int i = 0; i < n; i++)
dataTable[i] = null;
}
void add(MyObject x){
dataTable[x.key] = x;
}
boolean find(int key){
if (dataTable[key] != null)
return true;
else
return false;
}
}
We can use the key itself to index into the data being stored.
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- using data set values and variable names outside of the
- c and the net platform
- create awesome latex table with knitr kable and kableextra
- data bases and ado
- data structures and object oriented design viii
- convert datatable to xml with schema in c
- react mui datatable
- c datatable where clause
- itextsharp datatable to pdf c
- requirements
Related searches
- object oriented programming in matlab
- matlab object oriented programming pdf
- disadvantages of object oriented programming
- object oriented programming tutorial pdf
- object oriented programming book pdf
- object oriented programming c pdf
- object oriented programming 2 pdf
- object oriented programming pdf download
- object oriented programming c book
- object oriented programming java examples
- object oriented programming language pdf
- object oriented programming python pdf