001 package net.sf.cpsolver.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 * @version
009 * IFS 1.1 (Iterative Forward Search)<br>
010 * Copyright (C) 2006 Tomáš Müller<br>
011 * <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
012 * Lazenska 391, 76314 Zlin, Czech Republic<br>
013 * <br>
014 * This library is free software; you can redistribute it and/or
015 * modify it under the terms of the GNU Lesser General Public
016 * License as published by the Free Software Foundation; either
017 * version 2.1 of the License, or (at your option) any later version.
018 * <br><br>
019 * This library is distributed in the hope that it will be useful,
020 * but WITHOUT ANY WARRANTY; without even the implied warranty of
021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
022 * Lesser General Public License for more details.
023 * <br><br>
024 * You should have received a copy of the GNU Lesser General Public
025 * License along with this library; if not, write to the Free Software
026 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
027 */
028
029 public class FastVector extends Vector implements EnumerableCollection {
030 private static final long serialVersionUID = 1L;
031
032 public FastVector() {
033 super();
034 }
035 public FastVector(int initialCapacity) {
036 super(initialCapacity);
037 }
038 public FastVector(int initialCapacity, int capacityIncrement) {
039 super(initialCapacity, capacityIncrement);
040 }
041 public FastVector(Collection c) {
042 super(c);
043 }
044
045 public Enumeration elements() {
046 return new Enumeration() {
047 int count = 0;
048 public boolean hasMoreElements() { return count < elementCount; }
049 public Object nextElement() { return elementData[count++]; }
050 };
051 }
052
053 public String toString() {
054 return size()+"/"+super.toString();
055 }
056 }