|
||||||
| 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. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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? |
| Sponsored Links |
|
|
|
|||||
|
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 cl***es 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 |
|
|||
|
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 |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
| Xav | ........ | 1323.18 |
| MeTh0Dz|Reb0rn | ........ | 1053.7 |
| morefood2001 | ........ | 879.43 |
| John | ........ | 877.37 |
| marwex89 | ........ | 869.98 |
| WingedPanther | ........ | 834.24 |
| Brandon W | ........ | 749.07 |
| chili5 | ........ | 310.39 |
| Steve.L | ........ | 241.84 |
| dcs | ........ | 216.02 |
Goal: 100,000 Posts
Complete: 82%