[snip:
On May 9, 10:43=A0pm, Chris Torek <nos...@[EMAIL PROTECTED]
> wrote:
> In article
<0f2fcd7d-9fd0-47cd-8458-d517e7def...@[EMAIL PROTECTED]
>Michael.Zhang <zhangqiuy...@[EMAIL PROTECTED]
> wrote:
>
> [in a reply to Ben Bacarisse]
>
> >I just want to make sure I got you right.You are suggesting:
> >typedef struct Table{ ...} Table;
> >Table * makeTable( void* size, void * data);
>
> I can only speak for myself, not for Ben Bacarisse, but I rather
> doubt that is what he is suggesting.
>
> In the absence of additional details, here is how *I* might do
> this. =A0Note that I prefer not to use "typedef" -- which does not
> actually define types -- at all, but there are some "pro-typedef"
> reasons. =A0See <http://web.torek.net/torek/c/types2.html>
for
> details on this.
>
> In this particular case, I might have a "table.h" file. =A0In table.h,
> one would find, e.g., the following (assuming the table is indexed
> by simple "row,column" integer-pairs):
>
> =A0 =A0 struct table;
>
> =A0 =A0 struct table *table_create(void);
> =A0 =A0 void *table_lookup(struct table *table, int row, int col);
> =A0 =A0 int table_insert(struct table *table, int row, int col, void
*data=
);
> =A0 =A0 void *table_delete(struct table *table, int row, int col);
> =A0 =A0 void table_iterate(struct table *table, void *aux,
> =A0 =A0 =A0 =A0 void (*iter)(struct table *table, void *aux,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0int row, int col, void
*data));=
> =A0 =A0 void table_destroy(struct table *table, int free_all_data);
>
> Note that there is no "{" after "struct table". =A0This means that
> the entire contents of a "struct table" are hidden. =A0So where are
> they? =A0The answer is: in table.c (or perhaps in table-impl.h, which
> is then #include-ed by table1.c and table2.c, if for some reason
> "table.c" is not suitable to be used as a single file).
>
> "Table clients", as it were, now have no idea what is *inside* a
> table. =A0They only know that they can "create" one, do "lookup"
> operations, do "insert" operations, do "delete" operations, ask to
> "iterate" a function (of their choosing) over all table entries,
> and "destroy" a table (with, in this case, optional automatic calls
> to free() on each table item, so that they need not write a "freeing
> iterator").
>
> There is still quite a bit exposed here. =A0For instance, this makes
> it clear that tables are indexed exclusively by integral (row,column)
> pairs. =A0We must also decide whether "iterate" is called for "empty"
> entries (e.g., if there is a row 7, but only a column 3 in row 7
> -- even though other rows have columns 0 through 5 -- does the
> user's iterator get called with NULL entries for columns 0, 1, 2,
> 4, and 5 on row 7?). =A0Nonetheless, the actual details of how the
> tables are implemented are safely tucked away: clients know only
> as much about tables as you choose to expose, while the "table
> server" code (in table.c) sees all the details.
>
> (Also, rather than "table", the above should probably called a
> "sparse matrix" anyway. =A0"Tables" might actually instead be hash
> tables that implement what one uses associative arrays for in
> languages like awk, for instance.)
> --
> In-Real-Life: Chris Torek, Wind River Systems
> Salt Lake City, UT, USA (40=B039.22'N, 111=B050.29'W) =A0+1 801 277 2603
> email: gmail (figure it out) =A0 =A0
=A0http://web.torek.net/torek/index.h=
tml
]
OFF TOPIC to previous discussion,reason being don't know where I
should post this question.
Thanks very much for all your replies. Seems most of you have a lot of
experiences in computer science. I might just ask you some questions
that I couldn't get advice from.
my problem is that I love computer science,i know how do study,but I
dont understand the material well enough, I am terrible computer
science student, I don't know what's gonna happen to person like me
after graduating with a GPA around C in CS.
I love computer science, cos I like programming, I enjoy debugging,
tracing down the logic and fix the bug. I am fancinated by the
algorithms being tought and problem solving skills I gained.
but, I am not doing well at all in my courses. My peer can finish a
programming assignment within 3 or 4 hours without help from TA at
all; while I can't progress much without help from others, it might
take me well over 20 hours even with help from others. I am not
efficient at programming at all.
Right now, I am taking a data structure and an algorithm course(Graph
theory,divide and conquer,danamic programming). I might barely pass my
data structure course, but fail the algorithm.
Before adding CS as another major, I studied some business courses
from accoutning and information systems,I did pretty well in thoese
courses,I believe I have a good study habbit.Lately, I have to admit
that I have to be a lot smarter to study Computer Science and I am not
at that level. I am sitting on the fence and don't know if I should
continue with CS(have taken 8 CS courses) or drop out of this major.
Any advice or opinion would be greatly appreciated.


|