Code example for Vector

Methods: add, clear

0
import java.util.Vector; 
 
class History { 
    private static final int VERSION_1 = 1;
    private static final int MAX_ENTRIES = 100;
    Vector<HistoryEntry> mEntries = new Vector<HistoryEntry>();
    int mPos;
    BaseAdapter mObserver;
 
    History() { 
        clear(); 
    } 
 
    History(int version, DataInput in) throws IOException {
        if (version >= VERSION_1) {
            int size = in.readInt();
            for (int i = 0; i < size; ++i) {
                mEntries.add(new HistoryEntry(version, in));
            } 
            mPos = in.readInt();
        } else { 
            throw new IOException("invalid version " + version);
        } 
    } 
 
    void setObserver(BaseAdapter observer) {
        mObserver = observer;
    } 
 
    private void notifyChanged() { 
        if (mObserver != null) {
            mObserver.notifyDataSetChanged();
        } 
    } 
 
    void clear() { 
        mEntries.clear();
        mEntries.add(new HistoryEntry(""));
        mPos = 0;
        notifyChanged(); 
    } 
 
    void write(DataOutput out) throws IOException {