I have to write a method that traverses a huge object's contents which are spread across machines and need to return this:
- starting index in the object's struct(ex: if it has 10 pieces/blocks I can return piece/block 3-7)
- offset within the first piece
- list/array of
pair < id of each piece, size of each piece >
(not map -I've been clearly told not to use Map or Map.Entry
)
Quoting exact words, I'm required to return fully-allocated array corresponding to the block range
.
Thought #1
: The starting index and offset are to be returned once, the option to create a class with
- index
- offset
- id
- size
and returning an array of this will be providing redundant information plus, adding 8 bytes every entry is huge waste of memory.
Thought #2
: I could create a data class with (id and size) and return another class with array of this smaller class + index & offset, but in this case the existence of my data class will be just to contain values which doesn't seem v. prudent.
Thought #3
:I've heard multiple times that people resort to arrays when need to return pairs. I don't know how to do that?