Annotation of researchv10no/cmd/cfront/libstring/test12.c, revision 1.1

1.1     ! root        1: // list test program.  Sorts standard input, prints with counts
        !             2: 
        !             3: #include "pair_list.h"
        !             4: 
        !             5: listoutimplement(pair)
        !             6: 
        !             7: pair_list
        !             8: sort(pair_list aList)  // straight insertion
        !             9: {
        !            10:        pair_list_iterator      unsorted(aList);
        !            11:        if ( unsorted.next() ) {
        !            12:                pair    p;
        !            13:                while ( unsorted.r_removeX(p) ) {
        !            14:                        pair_list_iterator      sorted = unsorted;
        !            15:                        pair    *q;  // pointer into sorted part
        !            16:                        while ( sorted.r_nextX(q) && q->name > p.name )
        !            17:                                ;
        !            18:                        if ( q->name < p.name )
        !            19:                                sorted.next();   // back up
        !            20:                        else if ( q->name == p.name ) {
        !            21:                                q->count++;
        !            22:                                continue;
        !            23:                        }
        !            24:                        sorted.r_insert(p);
        !            25:                }
        !            26:        }
        !            27:        return aList;
        !            28: }
        !            29: main()
        !            30: {
        !            31:        String  s;
        !            32:        pair_list       myList;
        !            33:        while (cin >> s)
        !            34:                myList.put(pair(s));
        !            35:        myOut(cout, sort(myList));
        !            36: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.