Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Java Source: CLArray (Dynamic array - ArrayList)

carray carrayobject dynamicarray dynamic generic arraylist array

  • Please log in to reply
10 replies to this topic

#1 Chall

Chall

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 349 posts
  • Location:Cedar Rapids, IA
  • Programming Language:Java
  • Learning:C, Java, C++, C#, Python, JavaScript, Assembly

Posted 24 October 2012 - 06:45 PM

Hello fellow residents of CC. I'm going to release the source code for my dynamic array (ArrayList). I contructed this as to get a better understanding of how the ArrayList in Java works, and so I made my own. It's very usefull, and I am even using it in my algebraic system solver.

CLArray is the lightweight version of CArray (which I'm not releasing simply because CLArray is better in every way). CLArray is similar to ArrayList, but with my own personal touch. It's very useful for storing varying information, or changing information, as it allows for vast modification of the array.

CLArray.java (Declared inside package util)
package util;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;

/**
 * CArray is an experimental alternative to ArrayList. It uses an internal array made out of CArrayObjects which hold values of the specified type.
 * CLArray is a version of CArray, but lighter than it's predecessor.
 * @author chall
 *
 * @param <T> type that the array will be of
 * @see CArrayObject
 * @since 1.0
 */
public final class CLArray<T> implements Iterable<T>, Collection<T>{
    
    /**
     * Internal array. This is the array that the client interacts with.
     */
    
    /*
     * Suppresses warnings because creating a generic array is impossible.
     */
    @SuppressWarnings("unchecked")
    private T[] array = (T[]) new Object[0];
    private int[] toRemove = new int[0];
    
    /**
     * Last index the class has used. This allows class to iterate faster.
     */
    
    /*
     * Last index used. Object uses this so that it takes less time to iterate.
     */
    private int lastIndex = 0;
    
    /**
     * How many new indexes to create when modifying array, so that the program does it less often (Faster).
     */
    
    /*
     * Used to determine how many extension to make to the array.
     */
    private int preLoadSize = 1;
    
    /**
     * Creates a new CArray with an initial length of length.
     * @param length length of initial array.
     */
    
    /*
     * Suppresses warnings because creating a generic array is impossible.
     */
    @SuppressWarnings("unchecked")
    public CLArray(int length){
        array = (T[]) new Object[length];
    }
    
    /**
     * Default constructor.
     */
    public CLArray(){
        
    }
    
    public CLArray(T[] all) {
        this.array = all;
    }

    /**
     * Returns the internal array itself for external usage and modification.
     * @return
     * @return the internal array
     */
    public T[] getAll(){
        return array;
    }
    
    /**
     * Used to get the index of the index on the array containing the comparator. Can throw RuntimeException.
     * @param comparator to find in array
     * @return index of the container containing the comparator, or -1 if one doesn't exist.
     * @throws RuntimeException if there is no array containing that value.
     * @see #contains(Object), RuntimeException
     */
    public int getIndexContaining(T comparator) {
        for(int i = 0; i < array.length; i++){
            if(array[i].equals(comparator) && array[i].hashCode() == comparator.hashCode()){
                return i;
            }
        }
        return -1;
    }
    
    /**
     * Checks whether or not the array is "full" (No value = null).
     * @return true if it is, false if it isn't
     */
    public boolean full(){
        for(int i = array.length-1; i > 0; i--)
            if(array[i] == null)
                return false;
        return true;
    }
    
    /**
     * Returns the first array index that is empty. Used when trying to avoid adding new members when there are still null values.
     * @return first empty array index
     * @see #get(int)
     */
    public int getFirstEmptyIndex(){
        for(int i = lastIndex; i < array.length; i++){
            if(array[i]==null){
                lastIndex = i+1;
                return i;
            }
        }
        for(int i = 0; i < lastIndex; i++){
            if(array[i]==null){
                lastIndex = i+1;
                return i;
            }
        }
        return -1;
    }
    
    /**
     * Adds an index to the array, and sets it to the object specified. Not to be used in place of set(T), which sets the value of an existing index.
     * @param object object of type T to be added.
     * @return
     * @see #set(int, Object);
     */
    public boolean add(T object){
        if(!full())
            array[getFirstEmptyIndex()] = object;
        else{
            array = Arrays.copyOfRange(array, 0, array.length+preLoadSize);
            array[array.length-preLoadSize] = object;
        }
        return true;
    }
    
    /**
     * Changes the stored value of an existing array index. Use add(T) if you need to create and set a new index and it's value.
     * @param index the index to modify.
     * @param object the object to add.
     * @throws ArrayIndexOutOfBoundsException if the specified index is impossible, or not yet existent.
     * @see #add(Object)
     */
    public void set(int index, T object) {
        if(index<array.length && index >= 0){
            array[index] = object;
        }else{
            throw new ArrayIndexOutOfBoundsException("CArray index out of bounds: "+index);
        }
    }
    
    /**
     * Used to retrieve stored values from the array based on their indexed location.
     * @param index index of array containing value.
     * @return value at the index specified.
     * @throws ArrayIndexOutOfBoundsException if the specified index is impossible, or not yet existent.
     */
    public T get(int index) {
        if(index < array.length && index >= 0){
            if(array[index] != null)
                return array[index];
            return null;
        }else{
            throw new ArrayIndexOutOfBoundsException("CArray index out of bounds: "+index);
        }
    }
    
    /**
     * Sets the length of the array to the size specified. Does not eliminate the values though, array keeps what it had previously, just new length.
     * @param size new length
     */
    public void setLength(int length){
        if(length >= 0){
            array = Arrays.copyOfRange(array, 0, length);
        }else{
            throw new NegativeArraySizeException("Negative array length: "+length);
        }
    }
    
    /**
     * Set the contained array to the specified array t.
     * @param t new array to contain
     */
    public void setArray(T[] t){
        this.array = t;
    }
    
    /**
     * Remove all null values from array, and then resizes array. No data will be lost, only null values will be removed, and array size will go down with the amount of null values removed.
     */
    public void removeNulls(){
        int trim = 0;
        for(int i = 0; i < array.length; i++){
            if(array[i]== null){
                for(int j = i; j < array.length-1; j++){
                    array[j] = array[j+1];
                }
                i-=1;
                trim++;
            }
        }
        array = Arrays.copyOfRange(array, 0, array.length-trim);
        lastIndex = 0;
    }
    
    private static boolean containsDuplicates(int[] o){
        for(int i = 0; i < o.length; i++){
            for(int j = 0; j < o.length; j++){
                if(i == j){
                    continue;
                }
                if(o[i] == o[j]){
                    return true;
                }
            }
        }
        return false;
    }
    
    private static int[] removeDuplicates(int[] toRemove2){
        int[] toReturn = toRemove2;
        for(int i = 0; i < toRemove2.length; i++){
            for(int j = 0; j < toRemove2.length; j++){
                if(i == j){
                    continue;
                }
                if(toRemove2[i] == toRemove2[j]){
                    for(int k = j; k < toRemove2.length-1; k++){
                        toReturn[k] = toReturn[k+1];
                    }
                    toReturn = Arrays.copyOf(toReturn, toReturn.length-1);
                    if(containsDuplicates(toReturn)){
                        toReturn = removeDuplicates(toReturn);
                    }
                }
            }
        }
        return toReturn;
    }
    
    /**
     * Remove all queued values from array, and then resizes array. No data will be lost, only queued values will be removed, and array size will go down with the amount of values removed.
     */
    public void removeQueuedIndexes(){
        toRemove = removeDuplicates(toRemove);
        int trim = 0;
        for(int i = 0; i < array.length; i++){
            for(int j : toRemove){
                if(i == j){
                    for(int k = j; k < array.length-1; k++){
                        array[k] = array[k+1];
                    }
                    trim++;
                }
            }
        }
        array = Arrays.copyOfRange(array, 0, array.length-trim);
        lastIndex = 0;
        toRemove = new int[0];
    }
    
    /**
     * Sets the preLoadSize (The amount of indexes created each time Arrays.copyOfRange is called).
     * @param size new size. Must be greater than 0
     */
    public void setPreLoad(final int size){
        if(size>0){
            this.preLoadSize = size;
        }
        else
            System.err.println("CArray error: PreLoad length must be greater than 0");
    }
    
    /**
     * Sets the container's value to null at the specified index.
     * @param index index of the value to make null
     * @throws ArrayIndexOutOfBoundsException if the specified index is impossible, or not yet existent.
     */
    public void flushIndex(int index){
        if(index >= 0 && index < array.length)
            queueIndexRemoval(index);
        else{
            throw new ArrayIndexOutOfBoundsException("CArray index out of bounds: "+index);
        }
    }
    
    /**
     * Sets all container's values to null.
     */
    public void flush(){
        for(int i = 0; i < array.length; i++){
            queueIndexRemoval(i);
        }
    }
    
    /**
     * Used to get the length of array including unused preloaded indexes, similar to when using regular array.
     * @return length of this array
     */
    public int length(){
        return array.length;
    }
    
    /**
     * Used to get the true length of array (length minus unused preloaded indexes), similar to when using regular array.
     * @return length of this array, minus the number of unused preloaded indexes.
     */
    public int trueLength(){
        if(array == null)
            return 0;
        if(array.length < preLoadSize){
            return array.length;
        }
        for(int i = array.length-1; i > array.length-preLoadSize; i--){
            if(array[i] != null){
                return i+1;
            }
        }
        return array.length;
    }
    
    @Override
    public String toString(){
	    if(array != null && array[0] != null)
		   return "First value: "+array[0]+", Last index: "+lastIndex+", PreLoadSize: "+preLoadSize+", Array true length: "+trueLength()+", Array length: "+length();
        return "Last index: "+lastIndex+", PreLoadSize: "+preLoadSize+", Array true length: "+trueLength()+", Array length: "+length();
    }
    
    /*
     * (non-Javadoc)
     * @see java.lang.Iterable#iterator()
     *
     * I don't know how this is honestly supposed to work.
     */
    @Override
    public Iterator<T> iterator() {
        return null;
    }

    @SuppressWarnings("unchecked")
    @Override
    public boolean addAll(Collection<? extends T> arg0) {
        for(T t : (T[]) arg0.toArray()){
            add(t);
        }
        return true;
    }

    @Override
    public void clear() {
        flush();
        removeQueuedIndexes();
    }

    @Override
    public boolean containsAll(Collection<?> arg0) {
        return Arrays.asList(array).containsAll(arg0);
    }

    @Override
    public boolean isEmpty() {
        for(T t : array){
            if(t != null){
                return false;
            }
        }
        return true;
    }

    @SuppressWarnings("unchecked")
    @Override
    public boolean remove(Object arg0) {
        if(Arrays.asList(array).contains(arg0)){
            queueIndexRemoval(getIndexContaining((T) arg0));
        }
        removeQueuedIndexes();
        return true;
    }

    @Override
    public boolean removeAll(Collection<?> arg0) {
        for(int i = 0; i < array.length; i++){
            for(Object c : arg0.toArray()){
                if(array[i] == c){
                    queueIndexRemoval(i);
                }
            }
        }
        removeQueuedIndexes();
        return true;
    }

    @Override
    public boolean retainAll(Collection<?> arg0) {
        boolean skip = false;
        for(int i = 0; i < array.length; i++){
            skip = false;
            for(Object c : arg0.toArray()){
                if(array[i] == c){
                    skip = true;
                }else if(skip){
                    continue;
                }
            }
            if(skip){
                continue;
            }
            queueIndexRemoval(i);
        }
        removeQueuedIndexes();
        return true;
    }

    @Override
    public int size() {
        return trueLength();
    }

    @Override
    public T[] toArray() {
        return array;
    }

    @Override
    public boolean contains(Object o) {
        return Arrays.asList(array).contains(o);
    }
    
    /*
     * (non-Javadoc)
     * @see java.util.Collection#toArray(T[])
     * Honestly I don't see what the point in this method is originally.
     */
    @Override
    public <T> T[] toArray(T[] a) {
        return a;
    }
    
    public void queueIndexRemoval(int i){
        if(i >= 0 && i < array.length){
            toRemove = Arrays.copyOf(toRemove, toRemove.length+1);
            toRemove[toRemove.length-1] = i;
        }
    }
}

*Examples of usage removed because of incompatibility with new updates*

DOWNLOADS
Attached File  CLArray.java   10.63KB   248 downloads (Declared inside package util)
  • 0
Speaks fluent Java

#2 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 31 October 2012 - 02:43 AM

Hey, I've read your code and here are my notes:

1) It's very odd (wrong) to use '==' for comparing your objects in contains / index search methods.
Take this class for example:
class Ball {
    private int size;
    public Ball(int size) {
	    this.size = size;
    }
    @Override
    public boolean equals(Object obj) {
	    if (obj instanceof Ball) {
		    return this.size == ((Ball) obj).size;
	    }
	    return false;
    }
    @Override
    public int hashCode() {
	    int hash = 3;
	    hash = 17 * hash + this.size;
	    return hash;
    }
}

With this main:
public static void main(String[] args) {
	    CLArray<Ball> balls = new CLArray<Ball>();
	    Ball ball1 = new Ball(1);
	    Ball ball2 = new Ball(1);
	    balls.add(ball1);
	   
	    System.out.println(ball1.equals(ball2) ? "Equal" : "Not Equal");
	    System.out.println(balls.getIndexContaining(ball2));
    }
And this will throw an error. Even though I told Java that both balls are equal.

2) getIndexContaining throws RuntimeException.
First of all, the throws declaration is not required, but ok.
But why throw an exception and not return -1 like all other kinds of lists? To do a safe index lookup you now need 2 lines, first doing contains, and then index search.

3) getfirstemptyindex won't always be correct
Using the same Ball class.
public static void main(String[] args) {
	    CLArray<Ball> balls = new CLArray<Ball>();
	    Ball ball1 = new Ball(1);
	    Ball ball2 = new Ball(2);
	    Ball ball3 = new Ball(3);
	    balls.add(ball1);
	    balls.add(ball2);
	    balls.add(ball3);
	   
	    balls.setLength(10);
	    System.out.println("First empty index: " + balls.getFirstEmptyIndex());
	    balls.set(0, null);
	    System.out.println("First empty index: " + balls.getFirstEmptyIndex());
	    balls.flushIndex(1);
	    System.out.println("First empty index: " + balls.getFirstEmptyIndex());
    }
Output:

First empty index: 3
First empty index: 4
First empty index: 5

I expect that setting the value at index 0 to null will not yield 0 as firstEmptyIndex, because the user has given it a value. After flushIndex, I would expect that to be the first empty index.
(And the empty index shouldn't raise anyway, for consecutive calls)


4) Odd null handling
Judging by the code, null is no valid entry for the array.
full() checks if there is a null left, if there is a null it's not full
firstEmptyIndex also uses the full()

However, you can add and sett nulls, which cause odd behaviour. Either throw nullpointers when you try to add or set null. Using a simple null check. Or handle nulls as proper values.
I suggest you try to handle nulls as proper values, because with setArray and getAll you loose control over the internal array.

Tip: in your get(int index) method
if (array[index] != null) {
    return array[index];
}
return null;
//Same without the if-statement, if it's null it'll return null..
return array[index];


5) length will give unexpected results
It may be fine with a preloadsize of 1, but anything else will give wrong length() results.
Well, they are correct if you want to know the internal array's length. But a user is only interested in the 'real' length.
public static void main(String[] args) {
	    CLArray<Ball> balls = new CLArray<Ball>();
	    balls.setPreLoad(5);
	    Ball ball1 = new Ball(1);
	    Ball ball2 = new Ball(2);
	    Ball ball3 = new Ball(3);
	    balls.add(ball1);
	    balls.add(ball2);
	    balls.add(ball3);
	   
	    System.out.println("length: " + balls.length());
    }
Result:

length: 5

A user expects 3.

I suggest you either change the length method. Or add a size() method to know the actual size (and then the nulls come into play again - count <> not count?).

6) toString
The current toString may be easy for you, the programmer of the class, but a user of the class would prefer to see the (first N) contents.

7) tiny one
supressswarning comments without suppresswarning
  • 0

#3 Chall

Chall

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 349 posts
  • Location:Cedar Rapids, IA
  • Programming Language:Java
  • Learning:C, Java, C++, C#, Python, JavaScript, Assembly

Posted 31 October 2012 - 12:15 PM

Hey, I've read your code and here are my notes:

1) It's very odd (wrong) to use '==' for comparing your objects in contains / index search methods.
Take this class for example:

class Ball {
private int size;
public Ball(int size) {
	 this.size = size;
}
@Override
public boolean equals(Object obj) {
	 if (obj instanceof Ball) {
		 return this.size == ((Ball) obj).size;
	 }
	 return false;
}
@Override
public int hashCode() {
	 int hash = 3;
	 hash = 17 * hash + this.size;
	 return hash;
}
}

With this main:
public static void main(String[] args) {
	 CLArray<Ball> balls = new CLArray<Ball>();
	 Ball ball1 = new Ball(1);
	 Ball ball2 = new Ball(1);
	 balls.add(ball1);
	
	 System.out.println(ball1.equals(ball2) ? "Equal" : "Not Equal");
	 System.out.println(balls.getIndexContaining(ball2));
}
And this will throw an error. Even though I told Java that both balls are equal.

2) getIndexContaining throws RuntimeException.
First of all, the throws declaration is not required, but ok.
But why throw an exception and not return -1 like all other kinds of lists? To do a safe index lookup you now need 2 lines, first doing contains, and then index search.

3) getfirstemptyindex won't always be correct
Using the same Ball class.
public static void main(String[] args) {
	 CLArray<Ball> balls = new CLArray<Ball>();
	 Ball ball1 = new Ball(1);
	 Ball ball2 = new Ball(2);
	 Ball ball3 = new Ball(3);
	 balls.add(ball1);
	 balls.add(ball2);
	 balls.add(ball3);
	
	 balls.setLength(10);
	 System.out.println("First empty index: " + balls.getFirstEmptyIndex());
	 balls.set(0, null);
	 System.out.println("First empty index: " + balls.getFirstEmptyIndex());
	 balls.flushIndex(1);
	 System.out.println("First empty index: " + balls.getFirstEmptyIndex());
}
Output:



First empty index: 3
First empty index: 4
First empty index: 5

I expect that setting the value at index 0 to null will not yield 0 as firstEmptyIndex, because the user has given it a value. After flushIndex, I would expect that to be the first empty index.
(And the empty index shouldn't raise anyway, for consecutive calls)


4) Odd null handling
Judging by the code, null is no valid entry for the array.
full() checks if there is a null left, if there is a null it's not full
firstEmptyIndex also uses the full()

However, you can add and sett nulls, which cause odd behaviour. Either throw nullpointers when you try to add or set null. Using a simple null check. Or handle nulls as proper values.
I suggest you try to handle nulls as proper values, because with setArray and getAll you loose control over the internal array.

Tip: in your get(int index) method
if (array[index] != null) {
return array[index];
}
return null;
//Same without the if-statement, if it's null it'll return null..
return array[index];


5) length will give unexpected results
It may be fine with a preloadsize of 1, but anything else will give wrong length() results.
Well, they are correct if you want to know the internal array's length. But a user is only interested in the 'real' length.
public static void main(String[] args) {
	 CLArray<Ball> balls = new CLArray<Ball>();
	 balls.setPreLoad(5);
	 Ball ball1 = new Ball(1);
	 Ball ball2 = new Ball(2);
	 Ball ball3 = new Ball(3);
	 balls.add(ball1);
	 balls.add(ball2);
	 balls.add(ball3);
	
	 System.out.println("length: " + balls.length());
}
Result:

length: 5

A user expects 3.

I suggest you either change the length method. Or add a size() method to know the actual size (and then the nulls come into play again - count <> not count?).

6) toString
The current toString may be easy for you, the programmer of the class, but a user of the class would prefer to see the (first N) contents.

7) tiny one
supressswarning comments without suppresswarning


Yes, I know about all these things, that's why It's not perfect yet. ;)
  • 0
Speaks fluent Java

#4 lethalwire

lethalwire

    while(false){ ... }

  • Senior Member
  • PipPipPipPipPipPip
  • 766 posts
  • Programming Language:C, Java, PHP, JavaScript
  • Learning:PHP

Posted 31 October 2012 - 02:40 PM

Yes, I know about all these things, that's why It's not perfect yet. ;)

Dear lord, if it's not correct please don't put it in the snippets section! :) Many user's come here looking for viable code.
What if a user were to take your code and try to implement an important project? They would surely expect correct results from your lists but they would yield otherwise, different (incorrect) results. If I were you, I'd refine the code by looking at DC's helpful comments ASAP.

Remember, before posting any type of data structure like this for others to use:
1. Test
2. Test
3. Test
  • 0

#5 Chall

Chall

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 349 posts
  • Location:Cedar Rapids, IA
  • Programming Language:Java
  • Learning:C, Java, C++, C#, Python, JavaScript, Assembly

Posted 31 October 2012 - 02:53 PM

Yes, I know about all these things, that's why It's not perfect yet. ;)

Dear lord, if it's not correct please don't put it in the snippets section! :) Many user's come here looking for viable code.
What if a user were to take your code and try to implement an important project? They would surely expect correct results from your lists but they would yield otherwise, different (incorrect) results. If I were you, I'd refine the code by looking at DC's helpful comments ASAP.

Remember, before posting any type of data structure like this for others to use:
1. Test
2. Test
3. Test

But, see, no one ever said that it doesn't work, it just doesn't work as well as it could. ;) Plus, I'm fixing it right now.
  • 0
Speaks fluent Java

#6 Chall

Chall

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 349 posts
  • Location:Cedar Rapids, IA
  • Programming Language:Java
  • Learning:C, Java, C++, C#, Python, JavaScript, Assembly

Posted 31 October 2012 - 03:24 PM

Updated and added/fixed what I could. All that it needs now is the iterator method, but honestly I don't know exactly how that's done. I'm worried it involves a pointer to the current iterable index, but I'm wondering if there is another way.

[Edit] Oops, double post. Sorry :(
  • 0
Speaks fluent Java

#7 lethalwire

lethalwire

    while(false){ ... }

  • Senior Member
  • PipPipPipPipPipPip
  • 766 posts
  • Programming Language:C, Java, PHP, JavaScript
  • Learning:PHP

Posted 31 October 2012 - 04:04 PM

What is the difference between CLArray and Oracle's implementation of java.util.ArrayList?
  • 0

#8 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 31 October 2012 - 04:12 PM

There's not meant to be much difference:

I contructed this as to get a better understanding of how the ArrayList in Java works


  • 0

#9 lethalwire

lethalwire

    while(false){ ... }

  • Senior Member
  • PipPipPipPipPipPip
  • 766 posts
  • Programming Language:C, Java, PHP, JavaScript
  • Learning:PHP

Posted 31 October 2012 - 05:07 PM

CLArray is similar to ArrayList, but with my own personal touch. It's very useful for storing varying information, or changing information, as it allows for vast modification of the array.

This is why I ask. ^^
"Personal touch" should be elaborated in the OP.
  • 0

#10 Chall

Chall

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 349 posts
  • Location:Cedar Rapids, IA
  • Programming Language:Java
  • Learning:C, Java, C++, C#, Python, JavaScript, Assembly

Posted 31 October 2012 - 06:30 PM

CLArray is similar to ArrayList, but with my own personal touch. It's very useful for storing varying information, or changing information, as it allows for vast modification of the array.

This is why I ask. ^^
"Personal touch" should be elaborated in the OP.


Well, some ideas I had for future versions of this is the ability to insert values or other arrays/collections directly into the CLArray, at any point, so all it does is push all the items in the range of the one being inserted up enough times so that the other value/array/collection can be just places value by value into the gap created.
I also had an idea of fixing up the original version (CArray), which has the ability to serialize the array (not sure if ArrayList has that function), and add some of the function I added above. I also still need to figure out how to write the iterator method.
  • 0
Speaks fluent Java

#11 Exabit

Exabit

    CC Newcomer

  • Member
  • PipPip
  • 22 posts
  • Location:Sydney Australia
  • Programming Language:Java
  • Learning:Python

Posted 18 January 2013 - 09:02 PM

Many of the methods and functions in the CLarray class are without (safe) use. For example the getFirstEmptyIndex.
Many arrays are actually meant to have null bits to represent data. The add method would be better off by taking an index parameter, like the set method.
The trim method has the same problem.
  • 0





Also tagged with one or more of these keywords: carray, carrayobject, dynamicarray, dynamic, generic, arraylist, array

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download