Forum Overview
::
Rants
::
Get dunked, son
[quote name="Entropy Stew"][quote name="Tansin A. Darcos (TDARCOS)"][quote name="Entropy Stew"]Read a book, read a book, read a motherfucking book.[/quote] I suggest that you learn something about programming, I don't need to "read a book" in this instance because it is clear that you do not know what you're talking about and I'll take real-world, operating code that works over some claims that do not relate to reality.[/quote] That makes zero sense (like everything else you've written) given that there was no choice between the two being offered. I told you your data structure is a hash collision, and it is. [quote]A hash table is used where someone uses a hash function to determine the insertion point of an item.[/quote] "Hash function": substring(token, 0, 1) [quote]I do not use the array as a hash table because I never insert anything into the table/array. The array of pointers just makes it easier to separate items by the first character.[/quote] A hash bucket is usually stored as a linked list in the case of a collision. Yours is sorted on insert instead of appended, so your insertion time is O(n) instead of O(1) like a normal hash collision. hash lookup: relevant_linked_list = lists[substring(token, 0, 1)]; // <a href="http://www.comp.nus.edu.sg/~ooiwt/tp/cs1102-0203-s1/lecture/10-hash.pdf">direct addressing table</a>, which is near enough to a hash table for me to make the analogy (and please note that I don't really care if you're doing a linear scan through the array instead, because that's just more for me to complain about) [quote]This is why I don't have to use a tree structure, I use the array of pointers to select by the first letter.[/quote] You don't have to use a tree structure ever, anywhere. Other people use them because they are faster and/or smaller. [quote]I never store any items in the array, thus it is neither a hash table nor are any of the elements hash buckets.[/quote] Lookup process for hash table collision: look up relevant bucket from data structure via hash function -> bucket is a linked list -> linear scan linked list to retrieve relevant item Lookup process for your data structure: look up relevant bucket from data structure via "hash function" -> bucket is a linked list -> linear scan linked list to retrieve relevant item [quote]If you want to argue that a linked list of pointers might represent a hash table, since it is using an index into memory (the pointer) that I might agree on. But not in this case.[/quote] I don't have to make that argument, nor would I. A linked list is exactly how a hash table usually stores elements in a bucket with a collision. Read a book. -/ES/-[/quote]