Calculates totals for columns.

@return void
187924
function _calculateTotals() {
        if (empty($this->_calculateTotals)) {
            return;
        }

        $this->addSeparator();

        $totals = array();
        foreach ($this->_data as $row) {
            if (is_array($row)) {
                foreach ($this->_calculateTotals as $columnID) {
                    $totals[$columnID] += $row[$columnID];
                }
            }
        }

        $this->_data[] = $totals;
        $this->_updateRowsCols();
    }
1198135
protected function calculateLastPage()
    {
        if (empty($this->total)) {
            $this->lastPage = 0;
            return;
        }

        if (empty($this->perPage)) {
            throw new \RuntimeException('Cannot calculate last page. Insufficient data');
        }

        $this->lastPage = (int) ceil($this->total / $this->perPage);
    }
169932
private function calculateColumnWidth()
    {
        foreach ($this->rows as $rowIndex => $row) {
            foreach ($row as $columnIndex => $column) {
                if ( ! isset($this->columnWidths[ $columnIndex ])) {
                    $this->columnWidths[ $columnIndex ] = strlen($column);
                } else {
                    if (strlen($column) > $this->columnWidths[ $columnIndex ]) {
                        $this->columnWidths[ $columnIndex ] = strlen($column);
                    }
                }
            }
        }

        return $this->columnWidths;
    }
638240
public function transpose() {
        $cpy = new static();
        $cpy->copy($this);

        for ($i=0; $i<static::ROWS; $i++) {
            for ($j=0; $j<static::COLUMNS; $j++) {
                $this[$i][$j] = $cpy[$j][$i];
            }
        }

    }
146419
public function calculate()
    {
        $this->calculatePageLimitAndOffset();
        $pageNumber = $this->getPageNumber();
        $offset = $this->getPaginationOffset();


        /* Setup page vars for display. */
        if ($pageNumber == 0) {
            $pageNumber = 1; //if no page var is given, default to 1.
        }
        $this->previous = $pageNumber - 1;
        $this->next = $pageNumber + 1;
        //last page is = total pages / items per page, rounded up.
        $this->lastPage = ceil($this->getTotalNumberOfPages() / $this->perPage);

        $this->lastPageMinusOne = $this->lastPage - 1;  //last page minus 1
        $this->create();
    }
227171
public static function sumColumns(array $data)
    {
        $columns = self::arrayColumns($data);

        if ($columns !== false){
            return self::columnSum($data, $columns);
        } else {
            return false;
        }
    }
1088423
public function getTotal()
    {
        $query = $this->getQuery()->select('COUNT(*) as total');

        $rows = $this->database->query($query, $this->database->getBinds());

        if (!isset($rows[0]['total'])) {
            return 0;
        }

        return $rows[0]['total'];
    }
55759
protected function recalculateTotal(): void
    {
        $this->total = $this->itemsTotal + $this->adjustmentsTotal;

        if ($this->total < 0) {
            $this->total = 0;
        }
    }
852039
def calculate_columns(self):
        """"""

        self.cols = int(math.ceil(len(self.elements) / float(self.rows)))
122170
protected function total($column, $display)
    {
        if (!is_callable($display) && !is_null($display)) {
            return $display;
        }

        $sum = $this->query->sum($column);

        if (is_callable($display)) {
            return call_user_func($display, $sum);
        }

        return $sum;
    }
1366063
public static function calculate()
    {
        foreach (self::$stackLog as &$data) {
            foreach (array('time', 'realmem' /* , 'emalloc' */) as $metric) {
                $data[$metric . '_end_relative'] = $data[$metric . '_end'] - self::$startValues[$metric];
                $data[$metric . '_start_relative'] = $data[$metric . '_start'] - self::$startValues[$metric];
                $data[$metric . '_total'] = $data[$metric . '_end_relative'] - $data[$metric . '_start_relative'];
            }
        }
    }
163637
public function __calculateSaveDownRows()
    {
        if (!$this->_columns) {
            foreach (get_object_vars($this) as $potential_column => $discard) {
                switch ($potential_column) {
                    case 'table':
                    case substr($potential_column, 0, 1) == "_":
                        // Not a valid column
                        break;
                    default:
                        $this->_columns[] = $potential_column;
                        break;
                }
            }
        }

        // reorder the columns to match get_class_schema
        //TODO: Write test to verify that this works right.
        foreach ($this->getClassSchema() as $schemaKey => $dontCare) {
            if (in_array($schemaKey, $this->_columns)) {
                $sortedColumns[$schemaKey] = $schemaKey;
            }
        }
        foreach ($this->_columns as $column) {
            if (!isset($sortedColumns[$column])) {
                $class_name = get_called_class();
                throw new Exception("No type hinting/docblock found for '{$column}' in '{$class_name}'.", E_USER_WARNING);
            }
        }

        $this->_columns = array_values($sortedColumns);

        // Return sorted columns.
        return $this->_columns;
    }
238854
public function getColumnCount()
    {
        $columnCount = 0;
        foreach ($this->_cells as $item) {
            if ($item->columns === 'auto') {
                continue;
            }
            $columnCount += $item->columns;
        }

        return $columnCount;
    }
657122
public function count($columns = '*')
    {
        $result = $this->getBuilder()->count($columns);

        // Reset query builder
        $this->resetBuilder();

        return (int) $result;
    }
763999
public function autosetColumns()
    {
        $value = $this->value;
        if (empty($this->columns)) {
            $dataValue = $value;
            if (count($dataValue)) {
                $firstValue = (array) $dataValue[0];
                foreach (array_keys($firstValue) as $header) {
                    $this->addColumn($header);
                }
            }
        }
    }
284381
public function addColumns($cols) {
        if (sizeof($cols) > 0) {
            foreach($cols as $col) {
                if (sizeof($col) == 3) {
                    $this->addColumn($col[0], $col[1], $col[2]);
                } else if (sizeof($col) == 2) {
                    $this->addColumn($col[0], $col[1]);

                }
            }
        }
    }
582644
public function setTotal($total)
    {
        $this->total = (int) $total;

        if ($this->total < 1) {
            $this->total = 1;
        }

        if ($this->page < 1) {
            $this->page = 1;
        } elseif ($this->page > $this->total) {
            $this->page = $this->total;
        }
    }