[Settings] [Home] [Contact] [Catalog] [Search] [Thread list] [Report] [Watcher] [PMs] [Admin]
[Return]

Report a post

Preview
>>140701
I am not sure what you mean by "classic", but every data structure has it's own benefits and drawbacks.

Associative array, AKA map, AKA dictionary, AKA hash table, is useful when you can't use simple number IDs. For example when you request a page from >>>/jp/ the server doesn't know if "jp" is the name of the first or second or third board in it's board list. It could do a loop and check every board's name, which works if there aren't many boards, but if there's 5000 boards then it would be better to use a hash table so you can just use the word "jp" as the key.

If you already know exactly what you need, then it would be better to use enums as the keys to a normal array. It's a more useful way to do >>140656 and looks like this:
#include <stdio.h>

enum {
A,
B,
HEYURI,
};
char * grades [] = {
[A] = "Excellent",
= "Boo...",
[HEYURI] = "The place to be!",
};
void main () {
printf(grades[HEYURI]); // Will print "The place to be!"
}[/a]
[/heyuri][/heyuri]
[a][heyuri][heyuri][/heyuri][/heyuri][/a]
Post number No.140715
Board Off-Topic@Heyuri
Optional. Describe what's wrong with it.