-
Type:
Enhancement
-
Status: Closed
-
Priority:
P4
-
Resolution: Won't Fix
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: specification
-
Subcomponent:
A DESCRIPTION OF THE PROBLEM :
It would be nice if objects (like ByteBuffer) could implement array operator overloading.
This way ByteBuffers could be a drop-in replacement for standard arrays making it easy to switch between normal arrays and ByteBuffers acting as arrays.
I'm sure other objects would benefit from this as well.
Maybe a special interface could be created that would require a getter/setter methods.
class ByteBuffer implements ArrayOperator<byte> {
public byte get(int idx) {return ...;}
public void set(int idx, byte value) { ... }
};
Then the following would be allowed:
ByteBuffer bb = ByteBuffer.alloc(1024);
bb[123] = 123;
Thanks,
It would be nice if objects (like ByteBuffer) could implement array operator overloading.
This way ByteBuffers could be a drop-in replacement for standard arrays making it easy to switch between normal arrays and ByteBuffers acting as arrays.
I'm sure other objects would benefit from this as well.
Maybe a special interface could be created that would require a getter/setter methods.
class ByteBuffer implements ArrayOperator<byte> {
public byte get(int idx) {return ...;}
public void set(int idx, byte value) { ... }
};
Then the following would be allowed:
ByteBuffer bb = ByteBuffer.alloc(1024);
bb[123] = 123;
Thanks,