No, an array, for example, why do I have to do this?:
for (int i = 0; i < bufferIndex-1; i++) {
buffer[i] = buffer[i + 1];
}
To remove the first element? (short of holding two indices)
> Yeah I understand that much, but I have a method that
> has a fixed length array, implemented as queue, so
> when the first element is "removed", I'd want all the
> other elements shifted to the left.
You'll need to write the code to "shift left" yourself, or use an existing implementation of a queue (e.g., [url=http://java.sun.com/javase/6/docs/api/java/util/LinkedList.html]java.util.LinkedList[/url]).
> am I the only one who thinks it would be useful?
You just need to get more familiar with the existing API...
~
> I know this could be done with an arrayList, and I
> understand the method doesn't exist, but am I the
> only one who thinks it would be useful?
You're probably not the only one, but the ones who want that are using a simple array for the wrong reason. They should instead be using a dynamic collection such as ArrayList or LinkedList, etc.
actually saying that, the array I am using is a byte array, which works well for splitting strings, and to convert I would have to use a wrapper class, so maybe using this loop is the best idea?
I want to keep this as simple as possible, so I'm going to shy away from writing a circular buffer, thanks anyway.
> Yeah I understand that much, but I have a method that
> has a fixed length array, implemented as queue, so
> when the first element is "removed", I'd want all the
> other elements shifted to the left.
The easiest way to implement a queue in an array is using a circular queue. Removing the first element amounts to changing an index; structural modification of the array is unnecessary.
Edit: ..... just like DrLaszloJamf pointed out.