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

1.1     ! root        1: // list test program.  sort standard input
        !             2: #include "String.h"
        !             3: #include "list.h"
        !             4: 
        !             5: listdeclare(String)
        !             6: listoutimplement(String)
        !             7: 
        !             8: String_list
        !             9: sort(String_list in)   // quicksort
        !            10: {
        !            11:        String_list     low;
        !            12:        String_list     high;
        !            13:        String  middle;
        !            14:        if (in.length() <= 1)
        !            15:                return in;
        !            16:        in.getX(middle);
        !            17:        while(in) {
        !            18:                String  temp;
        !            19:                in.getX(temp);
        !            20:                int     c;
        !            21:                if ((c = temp.compare(middle)) < 0 )
        !            22:                        low.put(temp);
        !            23:                else if ( c > 0 )
        !            24:                        high.put(temp);
        !            25:        }
        !            26:        if ( low.length() > high.length() )
        !            27:                high.put(middle);
        !            28:        else
        !            29:                low.put(middle);
        !            30:        return sort(low) + sort(high);
        !            31: }
        !            32: 
        !            33: main()
        !            34: {
        !            35:        String  s;
        !            36:        String_list     myList;
        !            37:        /* input */
        !            38:        while (cin >> s)
        !            39:                myList.put(s);
        !            40:        cout << sort(myList) << "\n";
        !            41: }

unix.superglobalmegacorp.com

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