C container and persistent library ?

Discussion in 'C Programming' started by llothar, Mar 2, 2007.

  1. llothar

    llothar Guest

    Hello,

    i have a few program parts that need a downgrade from C++ to C.

    I looked at it and while emulating the class system manually is not
    that hard, i really miss my templates and container types. Is there
    any any library for c that has generic (aka void* pointer)
    hashtables, linked lists and maybe btree's ? If there is a way to read/
    write such containers to disk it would be perfect.

    Google didn't found anything but i can't believe that all you are
    rewritting this code all the time.
     
    llothar, Mar 2, 2007
    #1
    1. Advertising

  2. llothar <> wrote:
    > [ ... ] Is there
    > any any library for c that has generic (aka void* pointer)
    > hashtables, linked lists and maybe btree's ? If there is a way to read/
    > write such containers to disk it would be perfect.


    You might try glib, http://www.gtk.org/api/2.6/glib/index.html .

    --
    pa at panix dot com
     
    Pierre Asselin, Mar 3, 2007
    #2
    1. Advertising

  3. llothar

    user923005 Guest

    On Mar 2, 3:43 pm, "llothar" <> wrote:
    > Hello,
    >
    > i have a few program parts that need a downgrade from C++ to C.
    >
    > I looked at it and while emulating the class system manually is not
    > that hard, i really miss my templates and container types. Is there
    > any any library for c that has generic (aka void* pointer)
    > hashtables, linked lists and maybe btree's ? If there is a way to read/
    > write such containers to disk it would be perfect.
    >
    > Google didn't found anything but i can't believe that all you are
    > rewritting this code all the time.


    I like these:
    http://eternallyconfuzzled.com/jsw_home.aspx

    This is always an easy bet:
    http://sourceforge.net/search/index.php

    Wiki almost always has code links:
    http://en.wikipedia.org/wiki/Hash_table
    http://en.wikipedia.org/wiki/Linked_list
    http://en.wikipedia.org/wiki/Btree

    Or google:
    http://www.google.com/search?source...G:2005-27,GGLG:en&q=hash table algorithm code

    or whatever. It doesn't take much moxie to find this stuff.
     
    user923005, Mar 3, 2007
    #3
  4. llothar

    bluejack Guest

    On Mar 2, 4:59 pm, "user923005" <> wrote:

    > It doesn't take much moxie to find this stuff.


    But finding it does take the fun out of writing it
    yourself, which is what C is all about. Can you
    really call yourself a C programmer if you haven't
    implemented a generic self-serializing hashtable?

    -bluejack
     
    bluejack, Mar 3, 2007
    #4
  5. bluejack wrote:
    > On Mar 2, 4:59 pm, "user923005" <> wrote:
    >
    >> It doesn't take much moxie to find this stuff.

    >
    > But finding it does take the fun out of writing it
    > yourself, which is what C is all about. Can you
    > really call yourself a C programmer if you haven't
    > implemented a generic self-serializing hashtable?


    Rather you can call yourself a *good* programmer if you
    have implemented a *good* hash table.
     
    Yevgen Muntyan, Mar 3, 2007
    #5
  6. llothar

    CBFalconer Guest

    llothar wrote:
    >
    > i have a few program parts that need a downgrade from C++ to C.
    >
    > I looked at it and while emulating the class system manually is not
    > that hard, i really miss my templates and container types. Is there
    > any any library for c that has generic (aka void* pointer)
    > hashtables, linked lists and maybe btree's ? If there is a way to
    > read/write such containers to disk it would be perfect.
    >
    > Google didn't found anything but i can't believe that all you are
    > rewritting this code all the time.


    You mean you didn't enter a suitable search. As far as hashtables
    are concerned, see hashlib.zip, found at:

    <http://cbfalconer.home.att.net/download/>

    which puts virtually no restrictions on the type of data stored.
    Licensed under GPL, unless you negotiate another license.

    For btrees etc. look for Ben Pfaff.

    --
    Chuck F (cbfalconer at maineline dot net)
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net>
     
    CBFalconer, Mar 3, 2007
    #6
  7. llothar wrote:
    > Hello,
    >
    > i have a few program parts that need a downgrade from C++ to C.


    You misspelled "upgrade". Try trolling elsewhere.
     
    Martin Ambuhl, Mar 3, 2007
    #7
  8. On 2 Mar 2007 15:43:04 -0800, in comp.lang.c , "llothar"
    <> wrote:

    >Hello,
    >
    >i have a few program parts that need a downgrade from C++ to C.


    You mean it needs to be ported to a platform that doesn't support C...
    (you wont win friends here by implying that C is an inferior cousin to
    C++)

    >I looked at it and while emulating the class system manually is not
    >that hard, i really miss my templates and container types. Is there
    >any any library for c that has generic (aka void* pointer)
    >hashtables, linked lists and maybe btree's ? If there is a way to read/
    >write such containers to disk it would be perfect.


    C++ which relies extemsively on templates and the STL is going to be
    hard to port. I would suggest that you determine the algo you need to
    implement, and rewrite it.

    >Google didn't found anything but i can't believe that all you are
    >rewritting this code all the time.


    Porting from C++ to C is probably pretty rare.
    --
    Mark McIntyre

    "Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are,
    by definition, not smart enough to debug it."
    --Brian Kernighan
     
    Mark McIntyre, Mar 3, 2007
    #8
  9. llothar

    llothar Guest

    > You mean it needs to be ported to a platform that doesn't support C...
    > (you wont win friends here by implying that C is an inferior cousin to
    > C++)


    Exactly i want to port to HPUX but don't want to send the huge cheque
    to HP for there C++
    compiler. It's not the topic of this posting - but i see it as a
    downgrade - yes.

    And because it is a system extension for the ruby scripting language
    it is more natural to use only C.

    > >Google didn't found anything but i can't believe that all you are
    > >rewritting this code all the time.

    >
    > Porting from C++ to C is probably pretty rare.


    If you enter "C container library" or something like this you see that
    google makes no difference between C++ and C. I only found C++
    references, thats why i asked.
     
    llothar, Mar 3, 2007
    #9
  10. llothar

    Flash Gordon Guest

    llothar wrote, On 03/03/07 17:18:
    >> You mean it needs to be ported to a platform that doesn't support C...
    >> (you wont win friends here by implying that C is an inferior cousin to
    >> C++)

    >
    > Exactly i want to port to HPUX but don't want to send the huge cheque
    > to HP for there C++


    <OT>
    Try gcc then.
    </OT>

    <snip>

    >>> Google didn't found anything but i can't believe that all you are
    >>> rewritting this code all the time.

    >> Porting from C++ to C is probably pretty rare.

    >
    > If you enter "C container library" or something like this you see that
    > google makes no difference between C++ and C. I only found C++
    > references, thats why i asked.


    Generally the best way to implement things of significant complexity in
    C is not the same as in C++, so if you have to do it in C you are better
    off looking at the problem fresh to see what the best way of
    implementing it in C is.
    --
    Flash Gordon
     
    Flash Gordon, Mar 3, 2007
    #10
  11. llothar

    Ian Collins Guest

    llothar wrote:
    >>You mean it needs to be ported to a platform that doesn't support C...
    >>(you wont win friends here by implying that C is an inferior cousin to
    >>C++)

    >
    > Exactly i want to port to HPUX but don't want to send the huge cheque
    > to HP for there C++


    <OT>then use gcc and its "their"</OT>

    --
    Ian Collins.
     
    Ian Collins, Mar 3, 2007
    #11
  12. Yevgen Muntyan <> writes:
    > bluejack wrote:
    >> On Mar 2, 4:59 pm, "user923005" <> wrote:


    >>> It doesn't take much moxie to find this stuff.

    >>
    >> But finding it does take the fun out of writing it
    >> yourself, which is what C is all about. Can you
    >> really call yourself a C programmer if you haven't
    >> implemented a generic self-serializing hashtable?

    >
    > Rather you can call yourself a *good* programmer if you
    > have implemented a *good* hash table.


    And you can call yourself a *smart* programmer if you can find and use
    a good hash table that somebody else has already written.

    That's assuming your goal is to get the program working. If your goal
    is to learn how to implement a good hash table, then of course
    implementing it yourself is the only smart way to go.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Mar 3, 2007
    #12
  13. "llothar" <> writes:
    >> You mean it needs to be ported to a platform that doesn't support C...
    >> (you wont win friends here by implying that C is an inferior cousin to
    >> C++)

    >
    > Exactly i want to port to HPUX but don't want to send the huge cheque
    > to HP for there C++
    > compiler. It's not the topic of this posting - but i see it as a
    > downgrade - yes.


    <OT>
    gcc is free, it supports both C and C++, and it should work on HPUX.
    </OT>

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Mar 3, 2007
    #13
  14. llothar

    llothar Guest

    > <OT>
    > gcc is free, it supports both C and C++, and it should work on HPUX.
    > </OT>


    The ruby interpreter comes compiled with HP C compiler, don't want to
    run into problems linking HP and GCC executables.
    And much more important gcc is generating very slow code, that hurts
    on this old PA-RISC machines.
     
    llothar, Mar 3, 2007
    #14
  15. Ian Collins said:

    > llothar wrote:
    >>>You mean it needs to be ported to a platform that doesn't support
    >>>C... (you wont win friends here by implying that C is an inferior
    >>>cousin to C++)

    >>
    >> Exactly i want to port to HPUX but don't want to send the huge cheque
    >> to HP for there C++

    >
    > <OT>then use gcc and its "their"</OT>


    If you're going to flame someone else's grammar, at least get your own
    grammar right. It's "it's", not "its". "Its X" means "the X belonging
    to it", whereas "it's X" is a contraction of "it is X" or "it has X".
    You are also missing a comma.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at the above domain, - www.
     
    Richard Heathfield, Mar 3, 2007
    #15
  16. On 3 Mar 2007 09:18:28 -0800, in comp.lang.c , "llothar"
    <> wrote:

    >> You mean it needs to be ported to a platform that doesn't support C...
    >> (you wont win friends here by implying that C is an inferior cousin to
    >> C++)

    >
    >Exactly i want to port to HPUX but don't want to send the huge cheque
    >to HP for there C++


    why not install a free one?

    >compiler. It's not the topic of this posting - but i see it as a
    >downgrade - yes.


    then you're likely to find little sympathy in Comp.lang.c.

    --
    Mark McIntyre

    "Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are,
    by definition, not smart enough to debug it."
    --Brian Kernighan
     
    Mark McIntyre, Mar 3, 2007
    #16
  17. llothar

    Ian Collins Guest

    Richard Heathfield wrote:
    > Ian Collins said:
    >
    >
    >>llothar wrote:
    >>
    >>>>You mean it needs to be ported to a platform that doesn't support
    >>>>C... (you wont win friends here by implying that C is an inferior
    >>>>cousin to C++)
    >>>
    >>>Exactly i want to port to HPUX but don't want to send the huge cheque
    >>>to HP for there C++

    >>
    >><OT>then use gcc and its "their"</OT>

    >
    >
    > If you're going to flame someone else's grammar, at least get your own
    > grammar right. It's "it's", not "its". "Its X" means "the X belonging
    > to it", whereas "it's X" is a contraction of "it is X" or "it has X".
    > You are also missing a comma.
    >

    It wasn't a flame, I was correcting a word, not the grammar. My intent
    was to help the OP with a common English mistake, not flame.

    When I was at school, we were told never to precede and with a comma.

    --
    Ian Collins.
     
    Ian Collins, Mar 3, 2007
    #17
  18. On 3 Mar 2007 14:19:33 -0800, in comp.lang.c , "llothar"
    <> wrote:

    >> <OT>
    >> gcc is free, it supports both C and C++, and it should work on HPUX.
    >> </OT>

    >
    >The ruby interpreter comes compiled with HP C compiler, don't want to
    >run into problems linking HP and GCC executables.


    Shouldn't be any. This is still your best bet, and you should probably
    ask in a gcc group for more info,

    >And much more important gcc is generating very slow code, that hurts
    >on this old PA-RISC machines.


    Same comment.
    --
    Mark McIntyre

    "Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are,
    by definition, not smart enough to debug it."
    --Brian Kernighan
     
    Mark McIntyre, Mar 3, 2007
    #18
  19. llothar

    CBFalconer Guest

    Ian Collins wrote:
    > llothar wrote:
    >
    >>> You mean it needs to be ported to a platform that doesn't
    >>> support C... (you wont win friends here by implying that C is
    >>> an inferior cousin to C++)

    >>
    >> Exactly i want to port to HPUX but don't want to send the huge
    >> cheque to HP for there C++

    >
    > <OT>then use gcc and its "their"</OT>


    I suspect llothar is not a native English speaker, and is doing
    pretty well with the language. The crying shame is the native
    speakers who can't use grammar and can't spell.

    GCC is probably better than HPUX anyhow. Just guessing, no
    experience with HPUX.

    --
    Chuck F (cbfalconer at maineline dot net)
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net>
     
    CBFalconer, Mar 4, 2007
    #19
  20. llothar

    CBFalconer Guest

    Richard Heathfield wrote:
    > Ian Collins said:
    >

    .... snip ...
    >>
    >> <OT>then use gcc and its "their"</OT>

    >
    > If you're going to flame someone else's grammar, at least get your
    > own grammar right. It's "it's", not "its". "Its X" means "the X
    > belonging to it", whereas "it's X" is a contraction of "it is X"
    > or "it has X". You are also missing a comma.


    I think there is a strong correlation (among native English
    speakers) between correct grammar/spelling, and programming
    ability.

    --
    Chuck F (cbfalconer at maineline dot net)
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net>
     
    CBFalconer, Mar 4, 2007
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vivi Orunitia
    Replies:
    11
    Views:
    4,542
    Martijn Lievaart
    Feb 4, 2004
  2. Arne Vajhøj
    Replies:
    23
    Views:
    895
    Tom Anderson
    Aug 31, 2008
  3. jacob navia
    Replies:
    5
    Views:
    526
    jacob navia
    Sep 28, 2009
  4. jacob navia
    Replies:
    10
    Views:
    666
    jacob navia
    Oct 1, 2009
  5. gk
    Replies:
    7
    Views:
    1,029
    Tom Anderson
    Oct 12, 2010
Loading...

Share This Page