Exemple #1
0
local iproc getsort(string name)
{
    sortmode *s;
                                                                                
    for (s=smode; SortName(s); s++)  {
        dprintf(1,"GETSORT: Trying %s\n",SortName(s));
        if (streq(SortName(s),name))
            return SortProc(s);
    }
    error("%s: no valid sortname",name);
    return NULL;     /* better not get here ... */
}
// find an entry
GFSortEntry *GFileSorter::Find(const char *path)
{
    if (mustSort)
        SortName();
    int l=0;
    int r=entries.Length()-1;

    // binary search  terminate if interval below 1
    while ((l+1) < r) {

        int i = (l+r) / 2;
        int res = entries[i]->path.Compare(path);

        if (res<0) {
            r = i;
            continue;
        }
        else if (res>0) {
            l = i;
            continue;
        }
        else {
            return entries[i];
        }
    }
    return NULL;

}