Lost Password?

Go Back   CodeCall Programming Forum > Software Development > C and C++

Unregistered, Check out the Coder Battles in the Announcement and Game forums.

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-05-2007, 05:28 PM
~nn ~nn is offline
Newbie
 
Join Date: Feb 2007
Posts: 2
Credits: 0
Rep Power: 0
~nn is on a distinguished road
Exclamation STL for "C"

There was a need to develop STL-like functions (map,multimap,set,multiset,vector, and queue) for standard "C", those who worked with C++ STL know what I am talking about.
Functions in most cases work 20-30% faster than C++ STL and allow creating very small and fast executables.
I was just wondering if anybody, besides myself has a need for such a product?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 02-06-2007, 11:28 AM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 2,508
Last Blog:
wxWidgets is NOT code ...
Credits: 852
Rep Power: 28
WingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the rough
Default

I'm sure they exist for C. The difficulty with C is getting the template functionality to work the same way it does in C++. I would imagine it involves a tremendous number of void pointers, etc, and is generally ugly as all get out to work with.

I've seen classes on data types taught in C, which actually implement a number of those constructs from within C.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-06-2007, 02:09 PM
~nn ~nn is offline
Newbie
 
Join Date: Feb 2007
Posts: 2
Credits: 0
Rep Power: 0
~nn is on a distinguished road
Default

Basically it looks pretty good.
This is an example of using map and vector togehter:

Code:
{
char s[]="tstvec1 12 23  34 45 56 tstvec1_last";
char s1[]="tstvec2 12 23  34 45 56 67 78 tstvec2_last";
char s2[]="tstvec3 12 23  34 45 56 43 56 89 tstvec3_last";
char s3[]="tstvec4 1 2  3 4 5 6 7 8 9 tstvec4_last";
void *vp;
Vec *vecP;
char fnd[50];
MR mp;
int i,j,k;
Vec *vPtr4;
Vec *vPtr5;
int key;

    mPtr = Map_Start(MULTI_MAP,STR,100);
    vPtr = vecStart(STR,100);
    vPtr1 = vecStart(STR,100);
    vPtr2 = vecStart(STR,100);
    vPtr3 = vecStart(STR,100);

    vecSplit(vPtr,' ',s);
    vecSplit(vPtr1,' ',s1);
    vecSplit(vPtr2,' ',s2);
    vecSplit(vPtr3,' ',s3);

    Map_StrAdd(mPtr,"Vec",(void*)vPtr);
    Map_StrAdd(mPtr,"Vec1",(void*)vPtr1);
    Map_StrAdd(mPtr,"Vec2",(void*)vPtr2);
    Map_StrAdd(mPtr,"Vec3",(void*)vPtr3);

    strcpy(fnd,"Vec3");
    vecP = (Vec *)Map_FindByStrKey(mPtr,fnd);
    if ( vecP != NULL)
    {
            for(i=0;i<vecSize(vecP);i++)
            {
                    printf("Item from vecP = %s\n",vecStrGetOne(vecP,i));
            }
    }
    else printf ("MAP: item=%s not found\n",fnd);

    strcpy(fnd,"Vec1");
    vecP = (Vec *)Map_FindByStrKey(mPtr,fnd);
    if ( vecP != NULL)
    {
            for(i=0;i<vecSize(vecP);i++)
            {
                    printf("Item from vecP = %s\n",vecStrGetOne(vecP,i));
            }
    }
    else printf ("MAP: item=%s not found\n",fnd);

    sz = Map_Size(mPtr);

    for(i=0; i<sz;i++)
    {
        mp = Map_GetByIndx(mPtr,i);
        printf("Map Key=%s \n",mp.key);
        vecP = (Vec*)mp.item;

        if ( vecP != NULL)
        {
                for(j=0;j<vecSize(vecP);j++)
                {
                        printf("Index: %d Item from vecP = %s\n",i,vecStrGetOne(vecP,j));
                }
        }
    }
    Map_Print(mPtr);
    vecStop(vPtr);
    vecStop(vPtr1);
    vecStop(vPtr2);
    vecStop(vPtr3);
    Map_Stop(mPtr);

Last edited by Jordan; 02-06-2007 at 02:37 PM. Reason: Added Code Tags
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -5. The time now is 12:26 AM.

Contest Stats

Xav ........ 1333.07
MeTh0Dz|Reb0rn ........ 1059.52
John ........ 887.37
morefood2001 ........ 879.43
marwex89 ........ 869.98
WingedPanther ........ 851.68
Brandon W ........ 764.23
chili5 ........ 312.39
Steve.L ........ 254.16
dcs ........ 223.87

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 82%

Ads