« first day (1365 days earlier)      last day (1484 days later) » 

user6461957
11:29 AM
    Is it actually possible to implement a hash table in C with a 1D array of size m->capacity * (m->key_size + m->value_size)?

    typedef struct {
        char *data;
        unsigned long (*hash)(unsigned char *);
        size_t key_size;
        size_t value_size;
        size_t size;
        size_t capacity;
    } unordered_map_t;

On the topic of collision resolution via linear probing it occurred to me that I don't have a mechanism to detect empty buckets to put key-value pairs into when keys can potentially be 0 in value.
 
user6461957
3:47 PM
Here you go:

unordered_map.c: https://privatebin.net/?aaa806d67a7215a2#HDTHrAh8NzagJBCvXdsSF8c1KdMZyhporjC3U8Njo6pN
unordered_map.h: https://privatebin.net/?8f66692e89c18dc2#9PaaJJN13bqoMp1r59BrTquW2kw3sLmuu1JoWiWQV2x6

It's still unfinished though...
 
4:13 PM
I've got 130 lines of code that I wrote for this' weeks homework. Got 90% mostly because of ugly style of writing. Would it be a good idea to post my code on SO to ask people what they would change in my code and what do they think about the style ?
I know people there are very judgemental and I could easily end up with many downvotes , closing question or duplicating question.
 
There's a code review stackexchange
 
Oh really ? So I should be fine then , no worries about downvotes ?
 
well if you post it there and follow their rules
 
sure
 
what is the difference between a cache and a databse in the backend?
see diagram under "Index of system design topics"
2) in this diagram what do the squares underneath the sqaures for each service represent?
 
4:34 PM
Why is it bad to create a class that depends on a non-member function ? For example, I have a class Expression that takes prefix expression and a member function evaluate that evaluates the expression. However, I have a non-member function solve which the function evaluate depends on. My professor says I shouldnt do that.
 
@domocar1 I don't think it's bad. Depends on the details, if the free-function is only useful together with the class then grouping it in as a static member function communicates that better.
But if the free function is not directly tied to the class then it's more than fine
 
user6461957
I would guess that it is due too much dependencies.
 
user6461957
If I remember correctly, you need to implement the istream& operator>> with friend functions.
 
user6461957
Also goto has its use cases. You shouldn't generally treat rules as dogmas.
 
I dont know what to say
 
4:41 PM
I'm getting out my best Dijkstra impression: uhum: "Dogma considered harmful"
 
user6461957
Or let's state: follow good rules & practices most of the time, and if you think you need to make an exception, then you need to have a good reason to make that exception (e.g. using goto)
 
user6461957
At least that's how I roll. :)
 
user6461957
5:11 PM
So far I came up with these options on my own:

1. reserve one extra byte for each bucket to indicate whether that bucket is full or empty
2. add another layer of indirection, i.e., allocate heap memory for a 1D array consisting of pointer to key and pointer to value pairs, then heap allocate another dynamic 1D array (vector) that actually stores the keys and values sequentially (not cache friendly, and too complicated).
 
user6461957
So with option 2, I need to have 2 1D arrays that are separate from each other. An array of pointer pairs which point to a second array location individually.
 
user6461957
Option 3:

Let each bucket point to its own heap allocation (that is, it isn't contiguous), but then it leads to memory fragmentation and bad cache performance.
 
user6461957
5:29 PM
Option 1 is memory intensive: 1 byte for each bucket means 10k bytes when you have 10k buckets + bucket size * capacity.
 
6:33 PM
hello
I have a question
can someone help me?
@d03
 
6:46 PM
Just ask a question and wait until someone answer it.
 
I want my application to detect when i press the key D from the keyboard
and disable the input of it
globally everywhere
 
6:58 PM
if (key == VK_SPACE)
{

}
 
 
2 hours later…
user6461957
8:44 PM
@Castiel, what do you mean by "disable the input of it"?
 
user6461957
You should generally try to be more specific having your respondents in mind. Don't assume that they can read minds. ;)
 

« first day (1365 days earlier)      last day (1484 days later) »