Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-8081-

libgeneralist

Name: Anonymous 2011-09-12 22:56

So, /prog/, I'm writing a general library in C, with the aim of being somewhat inspired by libraries such as glib, but far lighter and cleaner. So far, I have a linked list implementation and a Unicode string implementation (this is incomplete), totalling 670 SLOC. The build system is cmake, the code is fully documented with doxygen. Of course, the library is in its infancy and far from finished; what other things should I implement? Any data structures? OS abstractions?

Name: Anonymous 2011-09-12 23:04

Kill yourself faggot.

Name: Anonymous 2011-09-12 23:07

>>2
Why, sir?

Name: Anonymous 2011-09-12 23:27

As for Data Structures, Binary Tree, Maybe some sort of self-balancing tree?, Map, and Hash Map are probably my most-used data structures.

Also, something like STL's Vector and Java's ArrayList would be nice to have around.

Name: Anonymous 2011-09-12 23:28

You'll end up inventing a shitty implementation of Common Lisp, so stop now.

Name: Anonymous 2011-09-12 23:31

>>4
Question: how should I implement type agnosticism with the data structures? Void pointers or macros? Currently my linked list uses void pointers, because I feel dirty using macros.

Name: Anonymous 2011-09-12 23:35

>>6
Use void pointers. If you do it with macros, you'll end up with unreadable garbage (from a user's perspective).

Name: Anonymous 2011-09-12 23:36

>>7
Thanks.

Name: Anonymous 2011-09-12 23:49

First I read:
with the aim of being somewhat inspired by libraries such as glib, but far lighter and cleaner.

But then, immediately after:
>So far, I have a linked list implementation

How about you get rid of the linked-list implementation altogether, linked lists are poor data structures on modern computers. Dynamic arrays with overcommitting of memory to ammortize allocation cost is far superior. If you want to be lean and mean, focus only on the core data-structures that can be widely used with good performance, and less on the data-structures that are only taught about in elementary first year programming classes at university for historical reasons.

It's why ArrayList in Java and List in C#/.NET are in fact dynamic arrays and not linked-lists.

>Unicode string implementation (this is incomplete), totalling 670 SLOC.

A unicode string implementation in C in under 670 LOC? Something tells me you're doing it wrong. There's no way you can have proper conformance for UTF-8/UTF-16/UTF-32 character decoding, which is very important for security reasons. Do you know how big of a security problem shoddy Unicode text decoding code has caused the world?

Name: Anonymous 2011-09-12 23:50

>>9
Also, disregard my fail on the quotation.

Name: Anonymous 2011-09-12 23:53

>>9
I think I'll keep the linked list implementation, because it's fairly complete and nice. I'll also implement dynamic arrays.

The Unicode string implementation is incomplete, and by incomplete, I mean, it's currently unusable; I've basically just implemented the data structures. There is no UTF-{8,16,32} encoding/decoding yet, nor are there even formatting or searching functions.

Name: Anonymous 2011-09-12 23:57

>>9
Dynamic arrays with overcommitting of memory to ammortize allocation cost is far superior.
Enjoy your O(n) insertion.

Name: Anonymous 2011-09-13 0:05

>>9
I don't totally agree. A linked list with a proper memory manager with a freelist and whatnot is just fine, performance-wise.


>>12
only occasionally. That's the point of the overcommitting part. But dynamic arrays have problems with separation and composition. In a manually memory managed language, separation and composition aren't a good idea anyway, but, I mean, nobody would use a Lisp where cells were actually an abstraction over dynamic arrays. It would be horribly slow. Every call to car and cdr would have to break apart an array. Gross.

My point is that lists lend themselves really well to functional programming/recursion/automatic memory management. They are even, marginally, more optimized for those tasks.

Name: Anonymous 2011-09-13 0:07

>>9,10 here

The more I think about what you're trying to accomplish, the more I realize that you and the people who have created similar libraries for C in the past are going completely against the grain regarding the strengths of C and falling into one of the major weaknesses of the languages.

General purpose data structure toolkits in C, including glib and friends, are all gargbage. And I'm afraid that anything you concoct will have no use other than to satisfy your curiosity. They have far worse performance compared to equivalents in the C++ Standard Library, due to function call overhead, pointer indirection with void pointers with the underlying objects allocated out-of-band, emphasis on linked lists and trees, and so on and so forth. And with C data structure toolkits, there's no easy way to abstract the underlying allocator like in C++... typically, everything is hardcoded to call malloc/free or global function pointers to functions with the same signature.

You want a dynamic array of objects of a given structure type?

Given:

typedef struct
{
   int value;
   char* name;
   /* some other shit */
}
entry;

How fucking hard is it to write:
[code]
typedef struct
{
   entry *entries;
   size_t num_entries;
   // whole bunch of other arrays and shit for all of the other data you want to keep track within this subsystem or module of the program
}
higher_level_data_structure;

higher_level_data_structure ctx;
ctx.num_entries = /* whatever */;
ctx.entries = (entry *)malloc(sizeof(entry) * ctx.num_entries);
// initialize other data within ctx here


And changing it to use a linear arena allocator instead of malloc isn't that difficult. On the otherhand dressing it up in a bunch of shit like glib doesn't add anything to your program.

As for things like associative data structures like trees or hash-maps, you don't need them for most thing. A lot of time, most of your data is immutable or constant, so you can just use qsort to sort your arrays and use bsearch (or a manual inlined binary-search loop, it's not that much code) to get O(log n) searches, like a tree, but with better performance due to better cache locality.

And where you actually need constant time insertion or removal, writing an optimized hard-coded associative hash-table with quadratic probing is only like 200 lines of code if you only implement the actual operations you need for your use cases. That's fucking nothing.

Stop fighting against the weaknesses of C and embrace the strengths.

Name: Anonymous 2011-09-13 0:13

>>14
good post. If you're trying to actually get stuff done in C, get stuff done in C the C way. Otherwise go all out and write/download a high level language implementation.

Name: Anonymous 2011-09-13 0:17

>>12
You don't need insertion for most things, you just need to add it to the end of the sequence, in which case dynamic arrays have ammortized constant time tail insertion.

>>13
My point is that lists lend themselves really well to functional programming/recursion/automatic memory management.

Sounds like Lisp hacker syndrome. Every call to car or cdr would not need to break apart an array, they need only provide a bounded view overtop of the underlying immutable array. How the fuck due you think lists work in Clojure? They sure as hell aren't linked lists underneath the hood. However, unlike CL, Clojure has strong referential transparency and immutability, so perhaps it wouldn't work quite as well for CL.

So in fact, I would argue that (immutable) arrays lend themselves far better to real functional than lists.

Name: Anonymous 2011-09-13 0:18

>>16
I meant:
So in fact, I would argue that (immutable) arrays lend themselves far better to real functional programming than lists.

Name: Anonymous 2011-09-13 0:22

[code][/code]

Name: Anonymous 2011-09-13 0:27

>>18
Sorry, I'm just in a wrotten mood, not necessarily due to this thread, and didn't bother to check for correctness.

Name: Anonymous 2011-09-13 0:30

Wow, this thread is full of fuckfail. Thanks /prog/.

Name: Anonymous 2011-09-13 0:30

>>19
rotten

Name: Anonymous 2011-09-13 0:37

>>20
Failure aside, the guy did have a point. Algorithmic toolkit libraries in C are considered harmful.

Name: Anonymous 2011-09-13 0:42

[code]dicks[/code]

Name: Anonymous 2011-09-13 0:48

>>16
most dynamic arrays are implemented in such a way that they never over-commit more than double the memory. (ie they double in size every time they grow)

I think it's totally reasonable to assume that the average case for an append to be two lists of the same size.

So no I'd say the average case would require O(n), not constant time.

Also one of the basic things in lisp is decomposing lists into function arguments with the "apply" function. I guess... I guess you could come up with a hack for a dynamic array implementation, but it would not be nearly as straightforward as "the list is now the argument stack. call the function."

also here's a purely functional function: one that takes a list and returns a new list that is twice as big and has each member repeated twice in a row. (a b c) --> (a a b b c c). (it's in a sort of lispy/haskelly pseudocode.)

(recursive-function (a)
  when a
  append (list (car a) (car a)) (self (cdr a)))

and so: first it would make a bunch of small arrays, and then go about appending them together in the worst way possible because the "head" would move /backward/ each time.

Gross, right? with cells you just move pointers around. Kills the cache but at least the time complexity is 1) good and 2) easy to reason about.



And Clojure's implementation is based on the JVM. I think it's safe to say that we are talking about some kind of typical bit of modern hardware, and not the JVM.

Name: Anonymous 2011-09-13 1:22

>>24
a better implementation is

(when a
cons (car a) (cons (car a) (self (cdr a))))

in this case the linked list implementation is much faster, and the dynamic array implementation is still very slow. Even worse, probably, because it appends backward big arrays onto the tails of small arrays.

Name: n3n7i 2011-09-13 1:40

Linked lists are easy to sort, but struggle with random access?

Name: Anonymous 2011-09-13 1:48

>>26
when do you actually use random access? I can think of one situation: image processing.

Everywhere else you are probably going to write some kind of tree data structure to optimize access for special purposes. At least this is what physics and graphcis algorithms do.

arrays are actually not that useful. The only nice thing about them is that they let you more easily utilize the structure of memory (which not coincidentally is more like a tree than a giant 1D plane) to obtain better performance through cache coherency. So instead of making your own trees and doing whatever you want with them, low level advocates say we should work with the trees we are given.

Name: n3n7i 2011-09-13 2:14

I've been mucking around with databases... they're everywhere

...Could you index a linked-list[ for random(ID-based) access]? i guess you'd need an ..array? of pointers? =)

Name: Anonymous 2011-09-13 2:23

>>27
maybe image processing is the key to the economy like the Internet was in the 90's.  Huge databases like Google are scary, but you get used to them.  Can you imagine what the 1890's would have been like with electrification!

Name: n3n7i 2011-09-13 2:47

>>... they're everywhere [-Direct- Random access on at least one table// using Primary / foreign keys] (Retrieving Data..?) // Sorting isn't super important in this case..

...An array of int's can effectively act as pointers to the elements in another array, probably with more 'stable' results? (No serializing plain old int's either...)
Can also Look-up in both directions // ID->Pos & Pos->ID
And Merge tables !

Name: n3n7i 2011-09-13 3:30


[tblX]
PK-[Xid], { tblXIndex-[Xindex] }, data here....


a dense(?) index field

Should allow for the usual array style sorting on look-up tables?...

Eg. get item id W on a sorted array?
check tblX[item W].Xid == W  /or?/ tblX[item W].Xindex = W
true ->item hasn't moved // we got it

else Xindex should point to our moved item...
tblX[ tblX[W].Xindex ].Xid = W (Ref. Integrity?)

if it doesn't ... the index hasn't been updated properly(?)
but it should be able to be fixed (its redundant?)

Name: n3n7i 2011-09-13 6:52

...that ichess code *remember?* used more than one foreign key (int --pointer) per record, so it kind of was a tree-like(??) struct across many 1D tables..?

{Each Board -> many(?) new possible boards} main tree

{all boards are split up and stored} inv-tree (Roots?)

Name: Anonymous 2011-09-13 9:27

>>9
A unicode string implementation in C in under 670 LOC? Something tells me you're doing it wrong. There's no way you can have proper conformance for UTF-8/UTF-16/UTF-32 character decoding, which is very important for security reasons. Do you know how big of a security problem shoddy Unicode text decoding code has caused the world?

Well, after some time working on the string implementation, I have a fully conformant UTF-8 decoder in 67 lines:

gstring gstring_from_utf8(gstring_serial t) {
    gstring s = gvector_alloc();
    intmax_t i, w = 0, ww = 0, b;
    gchar c = 0;
    for (i = 0; i < t->l; i++) {
        b = (intmax_t) t->d[i];
        if (b < 0x80) {
            /* ASCII byte */
            if (w) {
                /* premature ending to previous multi-byte sequence */
                gvector_append(s, (void *) 0xfffd);
                w = 0;
            }
            /* append the character as it is */
            gvector_append(s, (void *) b);
        } else if (b < 0xc0) {
            /* continuation byte */
            if (!w) {
                /* unwanted continuation byte */
                gvector_append(s, (void *) 0xfffd);
            } else {
                /* keep constructing temporary character */
                c |= (b & 0x3f) << (--w * 6);
                if (!w) {
                    /* construction done; append the character */
                    if (gstring_char_valid(c)) {
                        /* character is valid Unicode */
                        if ((c < 0x80) ||
                            (c < 0x800 && ww > 1) ||
                            (c < 0x10000 && ww > 2) ||
                            (c < 0x200000 && ww > 3) ||
                            (c < 0x4000000 && ww > 4) ||
                            (ww > 5)) {
                            /* overlong; reject the character */
                            gvector_append(s, (void *) 0xfffd);
                        } else {
                            /* good, allow the character */
                            gvector_append(s, (void *) c);
                        }
                    } else {
                        gvector_append(s, (void *) 0xfffd);
                    }
                }
            }
        } else if (b < 0xfe) {
            /* start byte of multi-byte sequence */
            if (w) {
                /* premature ending to previous multi-byte sequence */
                gvector_append(s, (void *) 0xfffd);
            }
            w = ww =
                (b < 0xe0) ? 1 :
                (b < 0xf0) ? 2 :
                (b < 0xf8) ? 3 :
                (b < 0xfc) ? 4 : 5;
            c = (b & ((1 << (6 - w)) - 1)) << (w * 6);
        } else {
            /* invalid bytes 0xFE/0xFF */
            gvector_append(s, (void *) 0xfffd);
        }
    }
    if (w) {
        /* end of stream and we're still waiting for continuation bytes */
        gvector_append(s, (void *) 0xfffd);
    }
    return s;
}


I've tested this implementation with incomplete sequences, unwanted continuation bytes, invalid bytes and overlong forms, and the function will not crash, nor output non-standard characters. A simple test program proves its usability:

#include <assert.h>
#include "../src/string.h"
int main() {
    gstring_serial utf8 = gvector_alloc();
    gstring s;
    intmax_t i;

    /* unwanted continuations, incomplete sequences and invalid bytes */

    for (i = 0x80; i <= 0xff; i++)
        gvector_append(utf8, (void *) i);

    /* overlong sequences */

    gvector_append(utf8, (void *) 0xc0);
    gvector_append(utf8, (void *) 0xaf);

    gvector_append(utf8, (void *) 0xe0);
    gvector_append(utf8, (void *) 0x80);
    gvector_append(utf8, (void *) 0xaf);

    gvector_append(utf8, (void *) 0xf0);
    gvector_append(utf8, (void *) 0x80);
    gvector_append(utf8, (void *) 0x80);
    gvector_append(utf8, (void *) 0xaf);

    gvector_append(utf8, (void *) 0xf8);
    gvector_append(utf8, (void *) 0x80);
    gvector_append(utf8, (void *) 0x80);
    gvector_append(utf8, (void *) 0x80);
    gvector_append(utf8, (void *) 0xaf);

    gvector_append(utf8, (void *) 0xfc);
    gvector_append(utf8, (void *) 0x80);
    gvector_append(utf8, (void *) 0x80);
    gvector_append(utf8, (void *) 0x80);
    gvector_append(utf8, (void *) 0x80);
    gvector_append(utf8, (void *) 0xaf);

    s = gstring_from_utf8(utf8);
    assert(s->l == 133);
    for (i = 0; i < s->l; i++)
        assert(gstring_charat(s, i) == 0xfffd);
    gvector_destroy(utf8);
    gvector_destroy(s);
    return 0;
}

Name: Anonymous 2011-09-13 9:31

Of course, that is not to imply that the string implementation is finished; I have at least these things to go:

* string ops e.g. searching, printf, etc.
* Unicode normalisation/collation/canonicalisation
* UTF-8 encode
* UTF-16 encode/decode
* UTF-32 encode/decode

Name: Anonymous 2011-09-13 9:32

ASCII is superior. No need to decode anything, maximum speed.

Name: Anonymous 2011-09-13 9:35

>>35
???????????????????? ???????????? ???????????????????? ???????????????? ???????? ???????? ???????????????? ???????????????????????????? ???????????????? ???????????????? ????????????????.

Name: Anonymous 2011-09-13 9:41

>>36
box box box box

Name: Anonymous 2011-09-13 9:42

>>37
2011
not using a Linux-based OS, most of which include DejaVu Sans
Condescending smirks and baseball bats aside, I seriously hope you don't do this.

Name: Anonymous 2011-09-13 9:47

>>38
I don't normally run amateur OSes, but when i do i pick LoseThos.

Name: Anonymous 2011-09-13 9:51

>>39
you can't read /prog/ in LoseThos. It can be coded in EBCDIC for all its worth.

Name: Anonymous 2011-09-13 10:29

ooc already has you beat by miles.

Name: Anonymous 2011-09-13 15:17

>>28
use keys that aren't numbers. They are just better.

hints you shouldn't be using a number for something: adding two of them doesn't make sense and is not useful.

Name: Anonymous 2011-09-13 15:33

[m]nice dubz >>44[m]

Name: Anonymous 2011-09-13 17:55

<--- Two unique digits

Name: Anonymous 2011-09-13 19:43

Goats in hats get

Name: n3n7i 2011-09-13 21:22

>>42
...Care to explain? I can't see how i'd use anything else..
Yeah adding two keys doesn't make a lot of sense...
Being able to increment a key with X+=1; is kind of nice though...

Name: Anonymous 2011-09-13 22:04

>>46
cretin

Name: n3n7i 2011-09-13 22:21

Eg. Using an array of structs to store chars..


aStruct[1].ID = 1, aStruct[1].Index = 1, aStruct[1].Val="A"
aStruct[2].ID = 2, aStruct[2].Index = 2, aStruct[2].Val="B"
aStruct[3].ID = 3, aStruct[3].Index = 3, aStruct[3].Val="C"
aStruct[4].ID = 4, aStruct[4].Index = 4, aStruct[4].Val="D"

A=Id-1 // B=2 / C=3 ... 

reSort?
aStruct[1].ID = 3, aStruct[1].Index = 3, aStruct[1].Val="C"
aStruct[2].ID = 4, aStruct[2].Index = 4, aStruct[2].Val="D"
aStruct[3].ID = 1, aStruct[3].Index = 1, aStruct[3].Val="A"
aStruct[4].ID = 2, aStruct[4].Index = 2, aStruct[4].Val="B"

A still equals Id-1 // B=2 / C=3 ...?

Name: n3n7i 2011-09-14 0:47

Probably another bad example... reSort #2?

aStruct[1].ID = 2, aStruct[1].Index = 4, aStruct[1].Val="B"
aStruct[2].ID = 3, aStruct[2].Index = 1, aStruct[2].Val="C"
aStruct[3].ID = 4, aStruct[3].Index = 2, aStruct[3].Val="D"
aStruct[4].ID = 1, aStruct[4].Index = 3, aStruct[4].Val="A"

Name: Anonymous 2011-09-14 0:47

>>48
>>49
ITT: offtopic bullshit

Name: Sussex Dev Team 2011-09-14 2:02

>>46,48-49
Please stop decreasing the average quality of posts where the name field is equal to the string "n3n7i".

Thank you.

Name: n3n7i 2011-09-14 3:29

>>50 Technically, you could just about call it a linked list?
Except index isn't actually linked to the record it resides in...
It could easily be turned into a linked version though?

Name: Anonymous 2011-09-14 3:38

n3n7i is trying so hard, it's adorable

Name: n3n7i 2011-09-14 3:40

if Index is taken to represent a Next pointer

aStruct[1].Value = "B" // .Next = 4

aStruct[4].Value = "A" // .Next = 3

aStruct[3].Value = "D" // .Next = 2

aStruct[2].Value = "C" // .Next = 1 (Loop?)

...Sorted without even moving the array entries?
...Its a linked list Array =)

Name: Anonymous 2011-09-14 4:31

>>52
>>54
Get the fuck out of my thread.

Name: Sussex Dev Team 2011-09-14 6:09

>>52,54
Please stop decreasing the average quality of posts where the name field is equal to the string "n3n7i".

Thank you.

Name: n3n7i 2011-09-14 6:37

>>53 == >>55 ? ^^

Name: Anonymous 2011-09-14 7:57

Hey guys what goinOh... Carry on then

Name: n3n7i 2011-09-14 20:48

>>55
....Sooo are you going to post something..? ...Else

hey >>58, sup?

Name: n3n7i 2011-09-15 3:41

>>1 No linked array-struct [L.a.st.]?

...also, don't you have to free each item seperately in a linked list?

Name: Anonymous 2011-09-15 3:59

>>60
Could you rephrase your questions? I don't understand them.

Name: Anonymous 2011-09-15 7:16

>>60
I think your searching for dicks¿ =)

Name: Anonymous 2011-09-15 15:08

>>62
your searching

What about my searching for dicks?

Name: n3n7i 2011-09-15 16:53

...heeheeheee =)
You can use Tries =) =)
... heehee =)

Name: n3n7i 2011-09-15 20:51

...Just for you >>n64
//-------------

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//-----------------------------

const char cBlock[30] ={"!abcdefghijklmnopqrstuvwxyz?"};

struct s_chNode{int ID, Index, PreVal, Value, Branch, Leaf;};

struct s_chNode *Blinks, *blink;

int iBlinkmax=0, iBlinks=0;

//-----------------------------

void initBlink(){
Blinks = (struct s_chNode *)malloc(sizeof(struct s_chNode));
}

//------------------------------

void incBlink(){
blink = realloc(Blinks,((iBlinkmax+=10)+2)* sizeof(struct s_chNode));
if (blink!=NULL) Blinks = blink;
}

//------------------

int BlinkScan(int BPreV, int BVal){
int iB, iHalt=-1;
for(iB=0;iB<iBlinks;iB++){
    if(Blinks[iB].Value == BVal)
        if(Blinks[iB].PreVal == BPreV) return iB;
    }
return -1;
}

//-----------------------
   
int BlinkEntry(int iD, int PreVal, int Val){
int iB=0;
iB = BlinkScan(PreVal, Val);
  if (iB!=-1) return iB;
if(iBlinkmax<=iD) incBlink();
Blinks[iD].ID = iD;
Blinks[iD].Index = 0;
Blinks[iD].PreVal = PreVal;
Blinks[iD].Value = Val;
Blinks[iD].Branch = 0;
Blinks[iD].Leaf = 0;
iBlinks++;
//printf("added %i", iBoards-1);
return iD;
}

//------------------

int AutoBlinkScan(int BPreV, int BVal){
int iB, iHalt=-1, BVMin = BVal;
for(iB=0;iB<iBlinks;iB++){
    if(Blinks[iB].PreVal == BPreV)
        if(Blinks[iB].Value <= BVMin){
            iHalt = iB;
            BVMin = Blinks[iB].Value;
            }
    }
return iHalt;
}

//----------------------------------

void BlinkSort(int Zion){
int i, ii, iZ, Zi, bspv, bsnv;
Zi=Zion;
bspv = Blinks[Zi].PreVal;
bsnv = Blinks[Zi].Value;
for(i=1;i<27;i++){
    iZ = BlinkScan(bspv, i);
    ii = AutoBlinkScan(i, 0);
    if(iZ!=-1){
        Blinks[Zi].Branch = iZ;
        Blinks[iZ].Leaf = ii;
        printf("%i - %i / %i\n", Zi, iZ, ii);
        Zi = iZ;
        }   
    }
}

//-----------------------------------

int GetLeaf(int ZionII){
int Zi;
Zi=ZionII;
while((Blinks[Zi].Leaf==0)+(Blinks[Zi].Branch!=0)==2){
    Zi = Blinks[Zi].Branch;
    }
return Zi;
}

//---------------------------

int scanChar(int cX){
  int Geti=0;
  while(Geti<=27){
    if((int) cBlock[Geti]==cX) return Geti;
    Geti++;
    }
  return 0;
}

//------------------------------

int main(int argc, char *argv[]){
  char  myStr[1000];
  int i=0, j=1, k=0, l=0, m=0, loopi=0, li=0;

  initBlink();
  BlinkEntry(iBlinks, 0, 0);

  if(argc>=1){
    loopi = strlen(argv[1]);
    for(li=0;li<loopi;li++){
        myStr[li] = argv[1][li];
        }
    } else {
    loopi=10;
    scanf("%10s", myStr);
    }
  while(((int) j!=0)+(i<loopi)==2){
    j= (int) myStr[i];
    printf("-%c -", j);
    k=scanChar(j);
    m=BlinkEntry(iBlinks, l, k);
    printf("%c-%c-%i-%i\n", cBlock[l], cBlock[k], m, i);
    l=k;
    i++;
    }
  BlinkSort(0);
  printf("\n");
  li=GetLeaf(0);
  while(Blinks[li].Branch>0){
    if(Blinks[li].Leaf>0){
        printf("\nli %i, leaf %i\n", li, Blinks[li].Leaf);
        BlinkSort(Blinks[li].Leaf);
        }
    if(Blinks[li].Branch>0) {
        li=GetLeaf(Blinks[li].Branch);
        }
    }
  printf("leaf %i\n", li);

  if(Blinks[li].Leaf>0){
    printf("\nli %i, leaf %i\n", li, Blinks[li].Leaf);
    BlinkSort(Blinks[li].Leaf);
    }

  /*BlinkSort(6);
  printf("\n");
  BlinkSort(17);
  printf("\n");
  BlinkSort(44);
  printf("\n");
  BlinkSort(33);
  printf("\n");
*/
  return 0;
}

//--------------

Name: n3n7i 2011-09-15 22:07

>>61
My bad... i probably don't know enough about making lib's...

So, if you have a linked list implementation, you call a function and it returns a linked list...?

Name: n3n7i 2011-09-15 22:31

Seems simple enough...

How could I build structures on-the-fly..?

Name: tdavis 2011-09-15 22:35

I want to stick my balls inside your rectum, n3n7i.

Name: n3n7i 2011-09-15 22:57

>>68 Anonymous grade wit...
 
...This may be useful >> ? Co-ordinate systems in databases??

Eg. you use two ints to locate an entry, with one representing the TABLE!, and the other the position in that table?

Name: n3n7i 2011-09-15 23:13

=) ... hee hee =)
... Or I could use tries >> ? Then build an IA =)
... heeheehee =) play chess >> though? with Tries? ...
... like n=b >> b<n =)

Name: n3n7i 2011-09-15 23:19

... Sorry my bad, not Tries... Mean hash >> hash tables? =)
Or ... Just linked list for index, ...? =)
indexes with >> linked list
... Might try some libs ... =)
... heehee =)

Name: Anonymous 2011-09-15 23:47

>>70,71 kill yourself, heehee =)

Name: Anonymous 2011-09-16 2:24

no one fucking cares heehee

Name: n3n7i 2011-09-16 3:08

>>65 + >>69 should be enough for a basic word-store, at least

//to clarify; how do i 'Define' a structure-variant on the fly, malloc-ing a hard-coded struct definition is no trouble, but can I 'soft-code' a struct?

Name: Anonymous 2011-09-16 3:23

>>74 cretin

Name: Anonymous 2011-09-16 3:37

>>74
You can't.  Now go to ##C so you can get your dick ripped off.

Furthermore, please stop decreasing the average ``quality of post'' for ∀Post("n3n7i").

Name: n3n7i 2011-09-16 3:43

i am a nigger please give me welfare

Name: n3n7i 2011-09-16 6:49

...Might not be such a problem hopefully, can just about use int's for everything?

//Side-by-side struct width extensions..?

Name: n3n7i 2011-09-17 6:31

io kliovme tzghevm diockls

klioiokl atz vmy sruperuioioru tzypiobngh sklioklkltzs

pruioghghkles ios ghioklaruioiorus

ghioiod kliorud io'vm ghavmiobngh a seiotzrurue gherue

ctzghruklghru fjtzghaghbn

Name: Anonymous 2011-09-17 6:46

>>1
C should have all this in stdlib, but it sucks so it doesn't. Let's see...

- I hope the Unicode strings library is not zero-terminated.
- A similar non-zero-terminated strings library for binrary-safe octet streams without any specific character encoding should be useful too, unless your Unicode strings library can handle invalid data and be used for this.
- Cons lists (as in Lisp)
- Variable-length, dynamically allocated vectors (as in Python)
- Dictionaries (as they work Python)
- Utilities to deal with and convert these as necessary
- Optional garbage collector? Don't implement a new one, see if you can include any other project.
- I'd leave OS abstractions last as you can use POSIX functionality, but if you get to it, overflows and shit C is missing, common terminal handling, low-level I/O, common ioctls, files and directories, sockets, threads and common process launching, handling and signaling are my top preferences.

>>5
He'll end making C useful?

>>6
I don't think C is fit for that (or anything lol), but if you think it is, esp. for dealing/iterating through lists and dictionaries, why not?

>>7-34
tl;dr

>>35
Die faggot

>>37
idiot idiot idiot idiot

Name: Anonymous 2011-09-17 6:52

>>80
- Cons lists (as in Lisp)
Enjoy your slow ass fucking in a language that generally doesn't support JIT.

Name: n3n7i 2011-09-17 9:01

... I malloc-ed and malloc-ed though =)
... Still can't make tries...
...heeheehee... =)

Name: Anonymous 2011-09-17 9:20

>>80
Thanks for all of the suggestions!

Name: n3n7i 2011-09-17 9:40

... I love suckling dog penises =)

The taste gives me a huge erection thehehehe ... =)

.. hehehehehehe =)

Name: Anonymous 2011-09-17 13:09

>>81
You realize you are talking about C, right?

Name: Anonymous 2011-09-17 14:57

>>39
>2011
>not running gentoo

Sure is /g/ in here.

Name: Anonymous 2011-09-17 15:35

>>85
Wtf, are you retarded or just plain stupid?

Name: Anonymous 2011-09-17 15:59

>>85
Yes. I haven't seen any C compilers that do JIT. The only way a programming language can use cons as a base building block and not be slow ass fuck is if it has a JIT, or a REALLY intelligent optimizer.

Name: Anonymous 2011-09-17 17:13

>>80
ooc has all that, and much more.

Name: Anonymous 2011-09-18 14:39

>>88
or a REALLY intelligent optimizer.
If you're writing C, it's called "the programmer."

Don't change these.
Name: Email:
Entire Thread Thread List