public function encodeBytes($b) { $nbits = $this->nbits; $base = $this->base; $size = intval($b->length * 8 / $nbits); $out = haxe_io_Bytes::alloc($size + (_hx_mod($b->length * 8, $nbits) === 0 ? 0 : 1)); $buf = 0; $curbits = 0; $mask = (1 << $nbits) - 1; $pin = 0; $pout = 0; while ($pout < $size) { while ($curbits < $nbits) { $curbits += 8; $buf <<= 8; $buf |= ord($b->b[$pin++]); } $curbits -= $nbits; $out->b[$pout++] = chr(ord($base->b[$buf >> $curbits & $mask])); } if ($curbits > 0) { $out->b[$pout++] = chr(ord($base->b[$buf << $nbits - $curbits & $mask])); } return $out; }
public function setup() { $this->data1 = new _hx_array(array()); $this->data2 = new _hx_array(array()); $scale = 1000; $cols = 5; $this->data1[$scale - 1] = null; $this->data2[$scale - 1] = null; $_g = 0; while ($_g < 2) { $k = $_g++; $_g1 = 0; while ($_g1 < $scale) { $i = $_g1++; $row = new _hx_array(array()); $row[$cols - 1] = null; $row[0] = "<supplier>"; $row[1] = "<product_code>"; $row[2] = "" . _hx_string_rec($i + $k * 7, ""); $row[3] = "" . _hx_string_rec(_hx_mod($i + $k * 7, 10), ""); $row[4] = "GBP"; if ($k === 1) { $this->data1[$i] = $row; } else { $this->data2[$i] = $row; } unset($row, $i); } unset($_g1); unset($k); } }
public function encodeBytes($bytes) { $base64 = parent::encodeBytes($bytes)->toString(); $remaining = 4 - _hx_mod(strlen($base64), 4); while ($remaining > 0 && $remaining < 3) { $base64 .= "="; --$remaining; } return haxe_io_Bytes::ofString($base64); }
public function base26($num) { $alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; if ($num < 0) { return "-"; } $out = ""; do { $out = _hx_string_or_null($out) . _hx_string_or_null(_hx_char_at($alpha, _hx_mod($num, 26))); $num = Math::floor($num / 26) - 1; } while ($num >= 0); return $out; }
static function mod($a, $b) { return _hx_mod($a, $b); }
public function computeOrdering($mods, $permutation, $permutationRev, $dim) { $to_unit = new haxe_ds_IntMap(); $from_unit = new haxe_ds_IntMap(); $meta_from_unit = new haxe_ds_IntMap(); $ct = 0; $_g = 0; while ($_g < $mods->length) { $mod = $mods[$_g]; ++$_g; if ($mod->add || $mod->rem) { continue; } if ($mod->sourceRow < 0) { continue; } if ($mod->sourcePrevRow >= 0) { $v = $mod->sourceRow; $to_unit->set($mod->sourcePrevRow, $v); $v; unset($v); $v1 = $mod->sourcePrevRow; $from_unit->set($mod->sourceRow, $v1); $v1; unset($v1); if ($mod->sourcePrevRow + 1 !== $mod->sourceRow) { $ct++; } } if ($mod->sourceNextRow >= 0) { $v2 = $mod->sourceNextRow; $to_unit->set($mod->sourceRow, $v2); $v2; unset($v2); $v3 = $mod->sourceRow; $from_unit->set($mod->sourceNextRow, $v3); $v3; unset($v3); if ($mod->sourceRow + 1 !== $mod->sourceNextRow) { $ct++; } } unset($mod); } if ($ct > 0) { $cursor = null; $logical = null; $starts = new _hx_array(array()); $_g1 = 0; while ($_g1 < $dim) { $i = $_g1++; $u = $from_unit->get($i); if ($u !== null) { $meta_from_unit->set($u, $i); $i; } else { $starts->push($i); } unset($u, $i); } $used = new haxe_ds_IntMap(); $len = 0; $_g2 = 0; while ($_g2 < $dim) { $i1 = $_g2++; if ($logical !== null && $meta_from_unit->exists($logical)) { $cursor = $meta_from_unit->get($logical); } else { $cursor = null; } if ($cursor === null) { $v4 = $starts->shift(); $cursor = $v4; $logical = $v4; unset($v4); } if ($cursor === null) { $cursor = 0; } while ($used->exists($cursor)) { $cursor = _hx_mod($cursor + 1, $dim); } $logical = $cursor; $permutationRev->push($cursor); $used->set($cursor, 1); 1; unset($i1); } $_g11 = 0; $_g3 = $permutationRev->length; while ($_g11 < $_g3) { $i2 = $_g11++; $permutation[$i2] = -1; unset($i2); } $_g12 = 0; $_g4 = $permutation->length; while ($_g12 < $_g4) { $i3 = $_g12++; $permutation[$permutationRev[$i3]] = $i3; unset($i3); } } }
static function getWeekDay($this1, $mondayBased = null) { if ($mondayBased === null) { $mondayBased = false; } $month = null; $days = Std::int(($this1 - 62135596800.0 - datetime__DateTime_DateTime_Impl_::yearStart($this1)) / 86400) + 1; $month = datetime_utils_DateTimeMonthUtils::getMonth($days, datetime__DateTime_DateTime_Impl_::isLeapYear($this1)); $a = Std::int((14 - $month) / 12); $y = datetime__DateTime_DateTime_Impl_::getYear($this1) - $a; $m = $month + 12 * $a - 2; $weekDay = null; $weekDay = _hx_mod(7000 + (datetime__DateTime_DateTime_Impl__3($a, $m, $mondayBased, $month, $this1, $weekDay, $y) + $y + Std::int($y / 4) - Std::int($y / 100) + Std::int($y / 400) + Std::int(31 * $m / 12)), 7); if ($mondayBased && $weekDay === 0) { return 7; } else { return $weekDay; } }
public function alignCore2($align, $a, $b) { if ($align->meta === null) { $align->meta = new coopy_Alignment(); } $this->alignColumns($align->meta, $a, $b); $column_order = $align->meta->toOrder(); $align->range($a->get_height(), $b->get_height()); $align->tables($a, $b); $align->setRowlike(true); $w = $a->get_width(); $ha = $a->get_height(); $hb = $b->get_height(); $av = $a->getCellView(); $ids = null; $ignore = null; if ($this->comp->compare_flags !== null) { $ids = $this->comp->compare_flags->ids; $ignore = $this->comp->compare_flags->getIgnoredColumns(); } $common_units = new _hx_array(array()); $ra_header = $align->getSourceHeader(); $rb_header = $align->getSourceHeader(); $_g = 0; $_g1 = $column_order->getList(); while ($_g < $_g1->length) { $unit = $_g1[$_g]; ++$_g; if ($unit->l >= 0 && $unit->r >= 0 && $unit->p !== -1) { if ($ignore !== null) { if ($unit->l >= 0 && $ra_header >= 0 && $ra_header < $a->get_height()) { $name = $av->toString($a->getCell($unit->l, $ra_header)); if ($ignore->exists($name)) { continue; } unset($name); } if ($unit->r >= 0 && $rb_header >= 0 && $rb_header < $b->get_height()) { $name1 = $av->toString($b->getCell($unit->r, $rb_header)); if ($ignore->exists($name1)) { continue; } unset($name1); } } $common_units->push($unit); } unset($unit); } $index_top = null; $pending_ct = $ha; $reverse_pending_ct = $hb; $used = new haxe_ds_IntMap(); $used_reverse = new haxe_ds_IntMap(); if ($ids !== null) { $index_top = new coopy_IndexPair($this->comp->compare_flags); $ids_as_map = new haxe_ds_StringMap(); $_g2 = 0; while ($_g2 < $ids->length) { $id = $ids[$_g2]; ++$_g2; $ids_as_map->set($id, true); true; unset($id); } $_g3 = 0; while ($_g3 < $common_units->length) { $unit1 = $common_units[$_g3]; ++$_g3; $na = $av->toString($a->getCell($unit1->l, 0)); $nb = $av->toString($b->getCell($unit1->r, 0)); if ($ids_as_map->exists($na) || $ids_as_map->exists($nb)) { $index_top->addColumns($unit1->l, $unit1->r); $align->addIndexColumns($unit1); } unset($unit1, $nb, $na); } $index_top->indexTables($a, $b, 1); if ($this->indexes !== null) { $this->indexes->push($index_top); } $_g4 = 0; while ($_g4 < $ha) { $j = $_g4++; $cross = $index_top->queryLocal($j); $spot_a = $cross->spot_a; $spot_b = $cross->spot_b; if ($spot_a !== 1 || $spot_b !== 1) { continue; } $jb = $cross->item_b->lst[0]; $align->link($j, $jb); $used->set($jb, 1); if (!$used_reverse->exists($j)) { $reverse_pending_ct--; } $used_reverse->set($j, 1); unset($spot_b, $spot_a, $jb, $j, $cross); } } else { $N = 5; $columns = new _hx_array(array()); if ($common_units->length > $N) { $columns_eval = new _hx_array(array()); $_g11 = 0; $_g5 = $common_units->length; while ($_g11 < $_g5) { $i = $_g11++; $ct = 0; $mem = new haxe_ds_StringMap(); $mem2 = new haxe_ds_StringMap(); $ca = _hx_array_get($common_units, $i)->l; $cb = _hx_array_get($common_units, $i)->r; $_g21 = 0; while ($_g21 < $ha) { $j1 = $_g21++; $key = $av->toString($a->getCell($ca, $j1)); if (!$mem->exists($key)) { $mem->set($key, 1); $ct++; } unset($key, $j1); } unset($_g21); $_g22 = 0; while ($_g22 < $hb) { $j2 = $_g22++; $key1 = $av->toString($b->getCell($cb, $j2)); if (!$mem2->exists($key1)) { $mem2->set($key1, 1); $ct++; } unset($key1, $j2); } unset($_g22); $columns_eval->push(new _hx_array(array($i, $ct))); unset($mem2, $mem, $i, $ct, $cb, $ca); } $sorter = array(new _hx_lambda(array(&$N, &$a, &$align, &$av, &$b, &$column_order, &$columns, &$columns_eval, &$common_units, &$ha, &$hb, &$ids, &$ignore, &$index_top, &$pending_ct, &$ra_header, &$rb_header, &$reverse_pending_ct, &$used, &$used_reverse, &$w), "coopy_CompareTable_0"), 'execute'); $columns_eval->sort($sorter); $columns = Lambda::harray(Lambda::map($columns_eval, array(new _hx_lambda(array(&$N, &$a, &$align, &$av, &$b, &$column_order, &$columns, &$columns_eval, &$common_units, &$ha, &$hb, &$ids, &$ignore, &$index_top, &$pending_ct, &$ra_header, &$rb_header, &$reverse_pending_ct, &$sorter, &$used, &$used_reverse, &$w), "coopy_CompareTable_1"), 'execute'))); $columns = $columns->slice(0, $N); } else { $_g12 = 0; $_g6 = $common_units->length; while ($_g12 < $_g6) { $i1 = $_g12++; $columns->push($i1); unset($i1); } } $top = Math::round(Math::pow(2, $columns->length)); $pending = new haxe_ds_IntMap(); $_g7 = 0; while ($_g7 < $ha) { $j3 = $_g7++; $pending->set($j3, $j3); unset($j3); } $added_columns = new haxe_ds_IntMap(); $index_ct = 0; $_g8 = 0; while ($_g8 < $top) { $k = $_g8++; if ($k === 0) { continue; } if ($pending_ct === 0) { break; } $active_columns = new _hx_array(array()); $kk = $k; $at = 0; while ($kk > 0) { if (_hx_mod($kk, 2) === 1) { $active_columns->push($columns[$at]); } $kk >>= 1; $at++; } $index = new coopy_IndexPair($this->comp->compare_flags); $_g23 = 0; $_g13 = $active_columns->length; while ($_g23 < $_g13) { $k1 = $_g23++; $col = $active_columns[$k1]; $unit2 = $common_units[$col]; $index->addColumns($unit2->l, $unit2->r); if (!$added_columns->exists($col)) { $align->addIndexColumns($unit2); $added_columns->set($col, true); } unset($unit2, $k1, $col); } unset($_g23, $_g13); $index->indexTables($a, $b, 1); if ($k === $top - 1) { $index_top = $index; } $h = $a->get_height(); if ($b->get_height() > $h) { $h = $b->get_height(); } if ($h < 1) { $h = 1; } $wide_top_freq = $index->getTopFreq(); $ratio = $wide_top_freq; $ratio /= $h + 20; if ($ratio >= 0.1) { if ($index_ct > 0 || $k < $top - 1) { continue; } } $index_ct++; if ($this->indexes !== null) { $this->indexes->push($index); } $fixed = new _hx_array(array()); if (null == $pending) { throw new HException('null iterable'); } $__hx__it = $pending->keys(); while ($__hx__it->hasNext()) { unset($j4); $j4 = $__hx__it->next(); $cross1 = $index->queryLocal($j4); $spot_a1 = $cross1->spot_a; $spot_b1 = $cross1->spot_b; if ($spot_a1 !== 1 || $spot_b1 !== 1) { continue; } $val = $cross1->item_b->lst[0]; if (!$used->exists($val)) { $fixed->push($j4); $align->link($j4, $val); $used->set($val, 1); if (!$used_reverse->exists($j4)) { $reverse_pending_ct--; } $used_reverse->set($j4, 1); } unset($val, $spot_b1, $spot_a1, $cross1); } $_g24 = 0; $_g14 = $fixed->length; while ($_g24 < $_g14) { $j5 = $_g24++; $pending->remove($fixed[$j5]); $pending_ct--; unset($j5); } unset($_g24, $_g14); unset($wide_top_freq, $ratio, $kk, $k, $index, $h, $fixed, $at, $active_columns); } } if ($index_top !== null) { $offset = 0; $scale = 1; $_g9 = 0; while ($_g9 < 2) { $sgn = $_g9++; if ($pending_ct > 0) { $xb = null; if ($scale === -1 && $hb > 0) { $xb = $hb - 1; } $_g15 = 0; while ($_g15 < $ha) { $xa0 = $_g15++; $xa = $xa0 * $scale + $offset; $xb2 = $align->a2b($xa); if ($xb2 !== null) { $xb = $xb2 + $scale; if ($xb >= $hb || $xb < 0) { break; } continue; } if ($xb === null) { continue; } $ka = $index_top->localKey($xa); $kb = $index_top->remoteKey($xb); if ($ka !== $kb) { continue; } if ($used->exists($xb)) { continue; } $align->link($xa, $xb); $used->set($xb, 1); $used_reverse->set($xa, 1); $pending_ct--; $xb += $scale; if ($xb >= $hb || $xb < 0) { break; } if ($pending_ct === 0) { break; } unset($xb2, $xa0, $xa, $kb, $ka); } unset($_g15); unset($xb); } $offset = $ha - 1; $scale = -1; unset($sgn); } $offset = 0; $scale = 1; $_g10 = 0; while ($_g10 < 2) { $sgn1 = $_g10++; if ($reverse_pending_ct > 0) { $xa1 = null; if ($scale === -1 && $ha > 0) { $xa1 = $ha - 1; } $_g16 = 0; while ($_g16 < $hb) { $xb0 = $_g16++; $xb1 = $xb0 * $scale + $offset; $xa2 = $align->b2a($xb1); if ($xa2 !== null) { $xa1 = $xa2 + $scale; if ($xa1 >= $ha || $xa1 < 0) { break; } continue; } if ($xa1 === null) { continue; } $ka1 = $index_top->localKey($xa1); $kb1 = $index_top->remoteKey($xb1); if ($ka1 !== $kb1) { continue; } if ($used_reverse->exists($xa1)) { continue; } $align->link($xa1, $xb1); $used->set($xb1, 1); $used_reverse->set($xa1, 1); $reverse_pending_ct--; $xa1 += $scale; if ($xa1 >= $ha || $xa1 < 0) { break; } if ($reverse_pending_ct === 0) { break; } unset($xb1, $xb0, $xa2, $kb1, $ka1); } unset($_g16); unset($xa1); } $offset = $hb - 1; $scale = -1; unset($sgn1); } } $_g17 = 1; while ($_g17 < $ha) { $i2 = $_g17++; if (!$used_reverse->exists($i2)) { $align->link($i2, -1); } unset($i2); } $_g18 = 1; while ($_g18 < $hb) { $i3 = $_g18++; if (!$used->exists($i3)) { $align->link(-1, $i3); } unset($i3); } if ($ha > 0 && $hb > 0) { $align->link(0, 0); } }
static function addYear($dt, $amount) { $year = datetime__DateTime_DateTime_Impl_::getYear($dt) + $amount; $time = $dt - 62135596800.0 - (datetime__DateTime_DateTime_Impl_::yearStart($dt) + datetime_utils_DateTimeMonthUtils::toSeconds(datetime_utils_DateTimeUtils_1($amount, $dt, $year), datetime__DateTime_DateTime_Impl_::isLeapYear($dt))); return datetime_utils_DateTimeUtils::yearToStamp($year) + datetime_utils_DateTimeMonthUtils::toSeconds(datetime_utils_DateTimeUtils_2($amount, $dt, $time, $year), _hx_mod($year, 4) === 0 ? datetime_utils_DateTimeUtils_3($amount, $dt, $time, $year) : false) + $time - 62135596800.0; }
static function get_random_cache_dir() { return chr(_hx_mod(Date::now()->getSeconds(), 26) + 65); }
static function gcd($m, $n) { while ($n !== 0) { $t = _hx_mod($m, $n); $m = $n; $n = $t; unset($t); } return $m; }