I wonder if something like this is possible without iterating over the entire hash:
collection = { red: 1000, green: 120, "yellow" => 1, blue: 999 }
Something like that:
collection.next_key(:red) #Should return :green
collection.prev_key(:blue) #Should return "yellow"
EDIT :: I was hoping somehow to gain access to the Ruby Hash member foreand backinternal data structure:
struct st_table_entry {
unsigned int hash;
st_data_t key;
st_data_t record;
st_table_entry *next;
st_table_entry *fore, *back;
};
( Source )
source
share