CPS 6, Ramm - Spring 2000 - 3/6/00 #20
- Announce
- Assignment #4
- Sample Quiz Handout
Chap 8. Arrays, Data, & Random Access
- A Draft Word in Context Program
-
context.cpp
- Redesigning a Word in Context Program
Redesign in Classroom
-
context2.cpp
- What if File is Too Large?
- Advantage of Vector Class: Resize
-
.resize(int size)
member function
- Copying/Cost: Memory and Time
- Double It!
-
.capacity()
member function
-
context3.cpp
- How to Solve Problem Without Vectors?
- Trailing Variables
- Limited Search
- or Reread File
- Translating Characters to Morse Code (char to string)
- Translate Table
-
morse.cpp
- "CryptoQuotes" (char to char)
-
transl.cpp
Size and Capacity: "The Partially Filled Array"
- Classical: Programmer keeps explicit track of each
- when passing vector argument, also pass size
- tvector
class: Class keeps explicit track of each
- requires use of special member functions
Using push_back
- Start with empty vector (capacity = 0)
- Use push_back to add elements
- Class does the rest
- Do not need to pass size a paramter!
A Simple Information Storage/Retrieval System
- Concepts
- Store lines from file in vector
- Retrieve lines by matching substrings
- Like UNIX grep program
-
getinfo.cpp
Improving the Storage/Retrieval System