@spivonious: An alternative depending on the question constraints is to just use an int array, treating the indices as the keys.