001: /*
002: * Copyright (C) Chaperon. All rights reserved.
003: * -------------------------------------------------------------------------
004: * This software is published under the terms of the Apache Software License
005: * version 1.1, a copy of which has been included with this distribution in
006: * the LICENSE file.
007: */
008:
009: package net.sourceforge.chaperon.common;
010:
011: /**
012: * This interface represents an abstract collection of integer values.
013: *
014: * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
015: * @version CVS $Id: IntegerCollection.java,v 1.3 2003/12/09 19:55:52 benedikta Exp $
016: */
017: public interface IntegerCollection {
018: /**
019: * Add a value to the collection.
020: *
021: * @param value Integer value.
022: *
023: * @return Index of this value.
024: */
025: public int add(int value);
026:
027: /**
028: * Add the values of an other integer collection.
029: *
030: * @param collection Collection of integer values.
031: */
032: public void add(IntegerCollection collection);
033:
034: /**
035: * Add the values of an array.
036: *
037: * @param array Array of integer values.
038: */
039: public void add(int[] array);
040:
041: /**
042: * Removes a value giving by an index.
043: *
044: * @param index Index of the integer value.
045: */
046: public void remove(int index);
047:
048: /**
049: * Replace a value, given by an index.
050: *
051: * @param index Index of the value, which should be replaced.
052: * @param value The new value.
053: */
054: public void set(int index, int value);
055:
056: /**
057: * Return a value from this collection.
058: *
059: * @param index Index of the value.
060: *
061: * @return Integer value.
062: */
063: public int get(int index);
064:
065: /**
066: * Returns the count of values in this collection.
067: *
068: * @return Count of integer values.
069: */
070: public int getCount();
071:
072: /**
073: * Return the index of a value, otherwise -1.
074: *
075: * @param value Value, which should found in this collection.
076: *
077: * @return Index of this value.
078: */
079: public int indexOf(int value);
080:
081: /**
082: * If the collection contains a value
083: *
084: * @param value Value, which should found in this collection.
085: *
086: * @return True, if this collection contains the value.
087: */
088: public boolean contains(int value);
089:
090: /**
091: * Removes a value from this collection.
092: *
093: * @param value Value to remove.
094: */
095: public void removeValue(int value);
096:
097: /**
098: * If this collection contains no values
099: *
100: * @return True, if the collection is empty
101: */
102: public boolean isEmpty();
103:
104: /**
105: * Pops a value of the end of this collection.
106: *
107: * @return Value from the end of the collection.
108: */
109: public int pop();
110:
111: /**
112: * Pushs a value on top to this collection.
113: *
114: * @param value Value, which should be added.
115: */
116: public void push(int value);
117:
118: /**
119: * Push values from an array on top on this collection.
120: *
121: * @param values Array of integer values.
122: */
123: public void push(int[] values);
124:
125: /**
126: * Peek a value of the end of this collection.
127: *
128: * @return Integer value.
129: */
130: public int peek();
131:
132: /**
133: * Removes all values from this collection.
134: */
135: public void clear();
136:
137: /**
138: * Swaps two values from this collection.
139: *
140: * @param index1 Index from the first value.
141: * @param index2 Index from the second value.
142: */
143: public void swap(int index1, int index2);
144:
145: /**
146: * Return a string representation of the collection.
147: *
148: * @return String representation of the collection.
149: */
150: public String toString();
151: }
|