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.21 2001/05/10 13:09:52 grubba Exp $ + // $Id: Table.pmod,v 1.22 2001/10/28 17:56:38 nilsson Exp $      #pike __REAL_VERSION__   #define TABLE_ERR(msg) throw(({ "(Table) "+msg+"\n", backtrace() }))      //! ADT.Table is a generic module for manipulating tables.   //!   //! Each table contains one or several columns.   //! Each column is associated with a name, the column name.   //! Optionally, one can provide a column type. The Table module can do a number   //! of operations on a given table, like computing the sum of a column,
pike.git/lib/modules/ADT.pmod/Table.pmod:199:    {    array t = ({});    f = f || lambda(mixed x) { return x; };    columns = remap(arrayp(columns)?columns:({ columns }));    foreach(table, mixed row)    if(f(@rows(row, columns), @args))    t += ({ row });    return copy(t, fields, types);    }    -  //! This method calls the function @[f()] for each column each time a +  //! This method calls the function @[f] for each column each time a    //! non uniqe row will be joined. The table will be grouped by the    //! columns not listed. The result will be returned as a new table object.    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] });
pike.git/lib/modules/ADT.pmod/Table.pmod:251:    if(!sizeof(columns))    return sum();    array f = remap(fields) - remap(columns);    mapping m = mkmapping(f, Array.map(f, lambda(mixed unused)    { return lambda(mixed x1,    mixed x2)    { return x1; }; }));    return group(m);    }    -  //! This method calls the function @[f()] for all rows in the table. +  //! This method calls the function @[f] for all rows in the table.    //! The value returned will replace the values in the columns given    //! as argument to map. If the function returns an array, several    //! columns will be replaced. Otherwise the first column will be    //! replaced. The result will be returned as a new table object.    object map(function f, array(int|string)|int|string columns, mixed ... args)    {    int ap = arrayp(columns);    array t = copy_value(table);    if(!catch(columns = remap(ap?columns:({ columns })))) {    for(int r = 0; r < sizeof(t); r++) {