    001    package ifs.util;
    002
    003    import java.util.*;
    004
    005    /** Vector extension with faster enumeration.
    006     * In {@link FastVector#elements()}, no unnecessary check is made.
    007     *
    008     * @author <a href="mailto:muller@ktiml.mff.cuni.cz">Tomáš Müller</a>
    009     * @version 1.0
    010     */
    011
    012    public class FastVector extends Vector {
    013
    014        public FastVector() {
    015            super();
    016        }
    017        public FastVector(int initialCapacity) {
    018            super(initialCapacity);
    019        }
    020        public FastVector(int initialCapacity, int capacityIncrement) {
    021            super(initialCapacity, capacityIncrement);
    022        }
    023        public FastVector(Collection c) {
    024            super(c);
    025        }
    026
    027        public Enumeration elements() {
    028            return new Enumeration() {
    029                int count = 0;
    030                public boolean hasMoreElements() { return count < elementCount; }
    031                public Object nextElement() { return elementData[count++]; }
    032            };
    033        }
    034
    035        public String toString() {
    036            return size()+"/"+super.toString();
    037        }
    038    }