pike.git / lib / modules / ADT.pmod / Table.pmod

version» Context lines:

pike.git/lib/modules/ADT.pmod/Table.pmod:1:   // Table.pmod by Fredrik Noring, 1998 - // $Id: Table.pmod,v 1.4 1998/05/09 21:30:22 noring Exp $ + // $Id: Table.pmod,v 1.5 1998/05/09 22:13:58 noring Exp $      #define TABLE_ERR(msg) throw(({ "(Table) "+msg+"\n", backtrace() }))      class table {    static private mapping fieldmap;    static private array table, fields, types;       static private array|int remap(array|string|int cs, int|void forgive)    {    array v = ({});
pike.git/lib/modules/ADT.pmod/Table.pmod:146:    for(int r = 0; r < sizeof(table); r++)    t += ({ rows(table[r], cs) });    return copy(t, rows(fields, cs), rows(types, cs));    }       object remove(int|string ... cs)    {    return select(@remap(fields) - remap(cs, 1));    }    -  object filter(function f, array(int|string)|int|string cs, mixed ... args) +  object where(function f, array(int|string)|int|string cs, mixed ... args)    {    array t = ({});    cs = remap(arrayp(cs)?cs:({ cs }));    foreach(table, mixed row)    if(f(@rows(row, cs), @args))    t += ({ row });    return copy(t, fields, types);    }       object group(mapping(int|string:function)|function f, mixed ... args)    {    if(!sizeof(table))    return this_object();       if(functionp(f)) { -  +  if(!arrayp(args[0])) +  args[0] = ({ args[0] });    f = mkmapping(args[0], allocate(sizeof(args[0]), f));    args = args[1..];    }       mapping m = ([]);    array cs = remap(indices(f));    f = mkmapping(cs, values(f));    array(int) keys = indices(fields) - cs;    foreach(table, array row) {    string key = encode_value(rows(row, keys));