Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   New release of the C Containers Library (CCL) (http://www.velocityreviews.com/forums/t736781-new-release-of-the-c-containers-library-ccl.html)

jacob navia 10-29-2010 11:40 PM

New release of the C Containers Library (CCL)
 
Hi

The new release contains a significant innovation: generic containers.

Generic containers are like virtual classes in the sense that you have
no creation function, i.e. you can never create a generic container,
only a specific kind of container (list, array, hash table, etc)

The iGenericContainer interface allows to treat all containers for
specific general functions the same. For instance

iGenericContainer.GetSize(someContainer);

will always return a size_t with the number of elements in the
container, no matter which container it is that is passed as argument.

The general container interface has no functions to add an element
however, since the syntax for sequential or associative elements
differ.

A further classification then, allows for those 2 branches:

Sequential containers (lists, arrays, string-arrays, bitststrings, etc)
and associative containers (hash-tables, trees) share with the generic
containers all the generic interface, adding some functions of their own.

This allows for writing of powerful completely general functions like
this "append" function (that is part of the generic sequential
containers interface):

static int Append(SequentialContainer *g1,SequentialContainer *g2)
{
int r;
void *element;
Iterator *it1 = newIterator((GenericContainer *)g2);
for (element = it1->GetFirst(it1);
element != NULL;
element = it1->GetNext(it1)) {
r = iGenericContainer.Add(g1,element);
if (r <=0) {
return r;
}

}
return 1;
}

This function will append to the first container the second one, no
matter what the exact types of g1 or g2 are.

Note that the iterators are part of the generic interface, not the
sequential one.

All of this is completely extensible and will work with ANY future
container that agrees to respect the defined protocol.

jacob

MartinBroadhurst 10-31-2010 09:01 PM

Re: New release of the C Containers Library (CCL)
 
On 29 Oct, 23:40, jacob navia <ja...@spamsink.net> wrote:
> Hi
>
> The new release contains a significant innovation: generic containers.
>
> Generic containers are like virtual classes in the sense that you have
> no creation function, i.e. you can never create a generic container,
> only a specific kind of container (list, array, hash table, etc)
>
> The iGenericContainer interface allows to treat all containers for
> specific general functions the same. For instance
>
> iGenericContainer.GetSize(someContainer);
>
> will always return a size_t with the number of elements in the
> container, no matter which container it is that is passed as argument.
>
> The general container interface has no functions to add an element
> however, since the syntax for sequential or associative elements
> differ.
>
> A further classification then, allows for those 2 branches:
>
> Sequential containers (lists, arrays, string-arrays, bitststrings, etc)
> and associative containers (hash-tables, trees) share with the generic
> containers all the generic interface, adding some functions of their own.
>
> This allows for writing of powerful completely general functions like
> this "append" function (that is part of the generic sequential
> containers interface):
>
> static int Append(SequentialContainer *g1,SequentialContainer *g2)
> {
> * * * * *int r;
> * * * * *void *element;
> * * * * *Iterator *it1 = newIterator((GenericContainer *)g2);
> * * * * *for (element = it1->GetFirst(it1);
> * * * * * * * * * * element != NULL;
> * * * * * * * * * * element = it1->GetNext(it1)) {
> * * * * * * * * *r = iGenericContainer.Add(g1,element);
> * * * * * * * * *if (r <=0) {
> * * * * * * * * * * * * *return r;
> * * * * * * * * *}
>
> * * * * *}
> * * * * *return 1;
>
> }
>
> This function will append to the first container the second one, no
> matter what the exact types of g1 or g2 are.
>
> Note that the iterators are part of the generic interface, not the
> sequential one.
>
> All of this is completely extensible and will work with ANY future
> container that agrees to respect the defined protocol.
>
> jacob


Surely Append would be more general, and more consise, it it took an
Iterator * as its first argument rather than a SequentialContainer *?

Martin

MartinBroadhurst 10-31-2010 09:32 PM

Re: New release of the C Containers Library (CCL)
 
On 31 Oct, 21:01, MartinBroadhurst <martin.broadhu...@gmail.com>
wrote:
>
> Surely Append would be more general, and more consise, it it took an
> Iterator * as its first argument rather than a SequentialContainer *?
>
> Martin
>
>


Sorry, I meant the *second* argument.

Martin

Anders Koeln 10-31-2010 09:38 PM

Re: New release of the C Containers Library (CCL)
 
MartinBroadhurst wrote:
> On 29 Oct, 23:40, jacob navia <ja...@spamsink.net> wrote:
>> The new release contains a significant innovation: generic containers.

>
> <snip>
>
> Martin


Please do not reply to spammers. Thank You.

BartC 10-31-2010 09:48 PM

Re: New release of the C Containers Library (CCL)
 
"jacob navia" <jacob@spamsink.net> wrote in message
news:iafm0l$jer$1@speranza.aioe.org...

> The new release contains a significant innovation: generic containers.


> This allows for writing of powerful completely general functions like
> this "append" function (that is part of the generic sequential containers
> interface):
>
> static int Append(SequentialContainer *g1,SequentialContainer *g2)
> {
> int r;
> void *element;
> Iterator *it1 = newIterator((GenericContainer *)g2);
> for (element = it1->GetFirst(it1);
> element != NULL;
> element = it1->GetNext(it1)) {
> r = iGenericContainer.Add(g1,element);
> if (r <=0) {
> return r;
> }
>
> }
> return 1;
> }


That looks more like a 'Concatenate' function.

'Append' would add the second argument as a single extra element at the end
of g1.

> This function will append to the first container the second one, no matter
> what the exact types of g1 or g2 are.


Do g1 and g2 have to be compatible types (in terms of what elements they
contain)?

--
bartc


Anders Koeln 10-31-2010 10:16 PM

Re: New release of the C Containers Library (CCL)
 
BartC wrote:
>



Please do not reply to spammers. Thank You.

Keith Thompson 10-31-2010 10:25 PM

Re: New release of the C Containers Library (CCL)
 
Anders Koeln <no@spam.invalid> writes:
> MartinBroadhurst wrote:
>> On 29 Oct, 23:40, jacob navia <ja...@spamsink.net> wrote:
>>> The new release contains a significant innovation: generic containers.

>>
>> <snip>
>>
>> Martin

>
> Please do not reply to spammers. Thank You.


He didn't. Please do not abuse the word "spammers" by applying it
to people who clearly are not spammers. Thank you.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

MartinBroadhurst 10-31-2010 10:37 PM

Re: New release of the C Containers Library (CCL)
 
On 31 Oct, 22:25, Keith Thompson <ks...@mib.org> wrote:

>
> > Please do not reply to spammers. Thank You.

>
> He didn't. *Please do not abuse the word "spammers" by applying it
> to people who clearly are not spammers. *Thank you.
>


There's something a bit fishy about "Anders Koeln". He doesn't appear
to be human. He may even be a fish. I shouldn't worry about what he
says.

Martin


Seebs 11-01-2010 12:29 AM

Re: New release of the C Containers Library (CCL)
 
On 2010-10-31, Anders Koeln <no@spam.invalid> wrote:
> Please do not reply to spammers. Thank You.


Jacob Navia is not a spammer. He's a regular participant and people have
previously talked about the design of this library here.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.

Kenny McCormack 11-01-2010 02:19 AM

Re: New release of the C Containers Library (CCL)
 
In article <iakpsm$rrj$1@speranza.aioe.org>,
Anders Koeln <no@spam.invalid> wrote:
>BartC wrote:
>>

>
>
>Please do not reply to spammers. Thank You.


We should spend all of our time telling each other who to respond to and
who not to. Good use of our time.

--
"The anti-regulation business ethos is based on the charmingly naive notion
that people will not do unspeakable things for money." - Dana Carpender

Quoted by Paul Ciszek (pciszek at panix dot com). But what I want to know
is why is this diet/low-carb food author doing making pithy political/economic
statements?

Nevertheless, the above quote is dead-on, because, the thing is - business
in one breath tells us they don't need to be regulated (which is to say:
that they can morally self-regulate), then in the next breath tells us that
corporations are amoral entities which have no obligations to anyone except
their officers and shareholders, then in the next breath they tell us they
don't need to be regulated (that they can morally self-regulate) ...



All times are GMT. The time now is 07:22 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.