New answers tagged

1

The statement "In (most? all?) programming languages, an index begins at zero" is simply not correct. Those languages whose heritage derives formally or informally from C follow this convention. Others may not. C did it that way because C was fundamentally intended to be a "high-level" assembler. It put a fair burden of the workload on the programmer, ...


0

Unless there has been a generator function which mapped all integers from 0 to 100,000 to the corresponding IDs (which I suppose you don't, as you said they are random), your best call is a regular hashmap. Storing them in a flat array will otherwise involve a lot of data movement whenever you insert new IDs. Second best option is to ditch the idea of using ...


-3

Every possible convention of counting has been tried. The counting from zero convention has become dominant because the alternatives tend to be more accident prone. See https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html for one explanation of why this version works out better.


7

It's about offsets. You have an address, which points to the location in memory where the array begins. Then to access any element, you multiply the array index by the size of the element and add it to the starting address, to find the address for that element. The first element is at the starting point, so you multiply the size of the element by zero ...


0

You have three options for storage on an Android device: Shared Preferences Shared Preferences is a Key/Value store, intended to store a small amount of settings type data. It supports primitive types like strings and numbers, stored in an XML format. Shared Preferences are available throughout the application, and they persist between sessions. File ...



Top 50 recent answers are included