J
jimi_usenet
I need a special kind of collection, and I think what I need is a so
called cyclic array. But with some modifications.
I want to be able to set a max size. I want to set and get values at
certain indexes. And if I set a value at an index so that there is a
gap between this index and the last index, I want it to "pad" with
copies of the value of the last index. And I want to be able to insert
values anyware in the the collection and make it the last value.
Example:
I create a collection with the max size 5. I then do this:
myCollection.set(0, a);
myCollection.set(1, b);
myCollection.set(2, c);
myCollection.set(4, e);
Then the collection should look like this: {a, b, c, c, e}
If I then do this:
myCollection.setLast(0, f);
then I want the collection to look like this: {b, c, c, e, f}
Is there such a collection available in java 5.0? Or maybe some third
party package, tested and bug free? Because I know I can write this
myself, but it takes time and probably can contain bugs that I don't
see. And I hate to reinvent the wheel.
Regards
/Jimi
called cyclic array. But with some modifications.
I want to be able to set a max size. I want to set and get values at
certain indexes. And if I set a value at an index so that there is a
gap between this index and the last index, I want it to "pad" with
copies of the value of the last index. And I want to be able to insert
values anyware in the the collection and make it the last value.
Example:
I create a collection with the max size 5. I then do this:
myCollection.set(0, a);
myCollection.set(1, b);
myCollection.set(2, c);
myCollection.set(4, e);
Then the collection should look like this: {a, b, c, c, e}
If I then do this:
myCollection.setLast(0, f);
then I want the collection to look like this: {b, c, c, e, f}
Is there such a collection available in java 5.0? Or maybe some third
party package, tested and bug free? Because I know I can write this
myself, but it takes time and probably can contain bugs that I don't
see. And I hate to reinvent the wheel.
Regards
/Jimi