gnnogales
2008-09-30 19:28:58 UTC
a. append(Object element) – appending the element at the end of the vector
b. clear() – make the vector collection empty
c. contains(Object element) – check whether the vector contains the element
d. elementAt(int index) – access the element at the given index
e. indexOf(Object element) – find the index of the element
f. insertAt(int index, Object element) – insert the element at the given index
g. isEmpty() – check whether the vector is empty
h. removeAt(int index) – remove the element at the given index
i. remove(Object element) – remove the element from the vector
j. replace(int index, Object element) – replace the element at the given index with the given element
k. size() – get the number of elements in the current vector
l. ensureCapacity(int minCapacity) – make sure the vector gets at least the given capacity
m. clone() – returns a cloned copy of this vector
n. removeRange(int fromIndex, int toIndex) – removes from this vector all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive
o. toString() – returns a string representation of this vector, containing the String representation of each element
p. reverse() – reverse the elements in this vector
q. merge(MyVector vector2) – add all the elements in vector2 to the end of this vector
2. The MyVector class should be created in the collection package.
3. Your implementation should be a self-expanding vector, similar to the DynamicVector in the textbook or like what we discussed in class.
4. After implementing the MyVector class you will test your MyVector class. To test the MyVector class you will create a Lab03 class under the lab package.
5. In the Lab03 class you will do the following:
a. find out on internet what is the Fibonacci number
b. create a static method named test and do the following in this method
i. create an instance of MyVector
ii. add the first 25 Fibonacci numbers into the vector using Fibonacci function, not manually one by one
iii. print out the vector
iv. reverse all the elements
v. make a clone of the vector
vi. print out the original vector
vii. remove all the elements at any odd index of the original vector
viii. print out the original vector
ix. reverse the cloned vector
x. print out the cloned vector (this vector should still contain 25 in order elements)
xi. merge the cloned vector to the original vector
xii. print out the original vector