public function printMultiValueMap($map) { $lines = new _hx_array(array()); if (null == $map) { throw new HException('null iterable'); } $__hx__it = $map->keys(); while ($__hx__it->hasNext()) { unset($key); $key = $__hx__it->next(); $line = "" . _hx_string_or_null($key) . "="; $values = ufront_core__MultiValueMap_MultiValueMap_Impl_::getAll($map, $key); $values->sort(isset(Reflect::$compare) ? Reflect::$compare : array("Reflect", "compare")); $line .= _hx_string_or_null($values->join(",")); $lines->push($line); unset($values, $line); } $lines->sort(isset(Reflect::$compare) ? Reflect::$compare : array("Reflect", "compare")); return $lines->join("\n"); }
static function stringIt2Array($it, $sort = null) { $values = new _hx_array(array()); $__hx__it = $it; while ($__hx__it->hasNext()) { unset($val); $val = $__hx__it->next(); $values->push($val); } if ($sort) { $values->sort(array(new _hx_lambda(array(&$it, &$sort, &$values), "me_cunity_tools_ArrayTools_0"), 'execute')); } return $values; }
static function moveWithoutExtras($src, $dest) { if ($src->length !== $dest->length) { return null; } if ($src->length <= 1) { return new _hx_array(array()); } $len = $src->length; $in_src = new haxe_ds_IntMap(); $blk_len = new haxe_ds_IntMap(); $blk_src_loc = new haxe_ds_IntMap(); $blk_dest_loc = new haxe_ds_IntMap(); $_g = 0; while ($_g < $len) { $i = $_g++; $in_src->set($src[$i], $i); $i; unset($i); } $ct = 0; $in_cursor = -2; $out_cursor = 0; $next = null; $blk = -1; $v = null; while ($out_cursor < $len) { $v = $dest[$out_cursor]; $next = $in_src->get($v); if ($next !== $in_cursor + 1) { $blk = $v; $ct = 1; $blk_src_loc->set($blk, $next); $blk_dest_loc->set($blk, $out_cursor); } else { $ct++; } $blk_len->set($blk, $ct); $in_cursor = $next; $out_cursor++; } $blks = new _hx_array(array()); if (null == $blk_len) { throw new HException('null iterable'); } $__hx__it = $blk_len->keys(); while ($__hx__it->hasNext()) { unset($k); $k = $__hx__it->next(); $blks->push($k); } $blks->sort(array(new _hx_lambda(array(&$blk, &$blk_dest_loc, &$blk_len, &$blk_src_loc, &$blks, &$ct, &$dest, &$in_cursor, &$in_src, &$len, &$next, &$out_cursor, &$src, &$v), "coopy_Mover_0"), 'execute')); $moved = new _hx_array(array()); while ($blks->length > 0) { $blk1 = $blks->shift(); $blen = $blks->length; $ref_src_loc = $blk_src_loc->get($blk1); $ref_dest_loc = $blk_dest_loc->get($blk1); $i1 = $blen - 1; while ($i1 >= 0) { $blki = $blks[$i1]; $blki_src_loc = $blk_src_loc->get($blki); $to_left_src = $blki_src_loc < $ref_src_loc; $to_left_dest = $blk_dest_loc->get($blki) < $ref_dest_loc; if ($to_left_src !== $to_left_dest) { $ct1 = $blk_len->get($blki); $_g1 = 0; while ($_g1 < $ct1) { $j = $_g1++; $moved->push($src[$blki_src_loc]); $blki_src_loc++; unset($j); } unset($_g1); $blks->splice($i1, 1); unset($ct1); } $i1--; unset($to_left_src, $to_left_dest, $blki_src_loc, $blki); } unset($ref_src_loc, $ref_dest_loc, $i1, $blk1, $blen); } return $moved; }
public function asTable() { if ($this->has_properties && $this->metadata === null) { return $this->t; } if ($this->metadata === null) { return null; } $w = $this->t->get_width(); $props = new _hx_array(array()); if (null == $this->keys) { throw new HException('null iterable'); } $__hx__it = $this->keys->keys(); while ($__hx__it->hasNext()) { unset($k); $k = $__hx__it->next(); $props->push($k); } $props->sort(isset(Reflect::$compare) ? Reflect::$compare : array("Reflect", "compare")); $mt = new coopy_SimpleTable($w + 1, $props->length + 1); $mt->setCell(0, 0, "@"); $_g = 0; while ($_g < $w) { $x = $_g++; $name = $this->t->getCell($x, 0); $mt->setCell(1 + $x, 0, $name); if (!$this->metadata->exists($name)) { continue; } $vals = $this->metadata->get($name); $_g2 = 0; $_g1 = $props->length; while ($_g2 < $_g1) { $i = $_g2++; if ($vals->exists($props[$i])) { $mt->setCell(1 + $x, $i + 1, $vals->get($props[$i])); } unset($i); } unset($_g2, $_g1); unset($x, $vals, $name); } $_g11 = 0; $_g3 = $props->length; while ($_g11 < $_g3) { $y = $_g11++; $mt->setCell(0, $y + 1, $props[$y]); unset($y); } return $mt; }
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); } }
public function toOrder3() { $order = new _hx_array(array()); if ($this->reference === null) { if (null == $this->map_a2b) { throw new HException('null iterable'); } $__hx__it = $this->map_a2b->keys(); while ($__hx__it->hasNext()) { unset($k); $k = $__hx__it->next(); $unit = new coopy_Unit(null, null, null); $unit->l = $k; $unit->r = $this->a2b($k); $order->push($unit); unset($unit); } if (null == $this->map_b2a) { throw new HException('null iterable'); } $__hx__it = $this->map_b2a->keys(); while ($__hx__it->hasNext()) { unset($k1); $k1 = $__hx__it->next(); if ($this->b2a($k1) === -1) { $unit1 = new coopy_Unit(null, null, null); $unit1->l = -1; $unit1->r = $k1; $order->push($unit1); unset($unit1); } } } else { if (null == $this->map_a2b) { throw new HException('null iterable'); } $__hx__it = $this->map_a2b->keys(); while ($__hx__it->hasNext()) { unset($k2); $k2 = $__hx__it->next(); $unit2 = new coopy_Unit(null, null, null); $unit2->p = $k2; $unit2->l = $this->reference->a2b($k2); $unit2->r = $this->a2b($k2); $order->push($unit2); unset($unit2); } if (null == $this->reference->map_b2a) { throw new HException('null iterable'); } $__hx__it = $this->reference->map_b2a->keys(); while ($__hx__it->hasNext()) { unset($k3); $k3 = $__hx__it->next(); if ($this->reference->b2a($k3) === -1) { $unit3 = new coopy_Unit(null, null, null); $unit3->p = -1; $unit3->l = $k3; $unit3->r = -1; $order->push($unit3); unset($unit3); } } if (null == $this->map_b2a) { throw new HException('null iterable'); } $__hx__it = $this->map_b2a->keys(); while ($__hx__it->hasNext()) { unset($k4); $k4 = $__hx__it->next(); if ($this->b2a($k4) === -1) { $unit4 = new coopy_Unit(null, null, null); $unit4->p = -1; $unit4->l = -1; $unit4->r = $k4; $order->push($unit4); unset($unit4); } } } $top = $order->length; $remotes = new _hx_array(array()); $locals = new _hx_array(array()); $_g = 0; while ($_g < $top) { $o = $_g++; if (_hx_array_get($order, $o)->r >= 0) { $remotes->push($o); } else { $locals->push($o); } unset($o); } $remote_sort = array(new _hx_lambda(array(&$locals, &$order, &$remotes, &$top), "coopy_Alignment_0"), 'execute'); $local_sort = array(new _hx_lambda(array(&$locals, &$order, &$remote_sort, &$remotes, &$top), "coopy_Alignment_1"), 'execute'); if ($this->reference !== null) { $remote_sort = array(new _hx_lambda(array(&$local_sort, &$locals, &$order, &$remote_sort, &$remotes, &$top), "coopy_Alignment_2"), 'execute'); $local_sort = array(new _hx_lambda(array(&$local_sort, &$locals, &$order, &$remote_sort, &$remotes, &$top), "coopy_Alignment_3"), 'execute'); } $remotes->sort($remote_sort); $locals->sort($local_sort); $revised_order = new _hx_array(array()); $at_r = 0; $at_l = 0; $_g1 = 0; while ($_g1 < $top) { $o4 = $_g1++; if ($at_r < $remotes->length && $at_l < $locals->length) { $ur = $order[$remotes[$at_r]]; $ul = $order[$locals[$at_l]]; if ($ul->l === -1 && $ul->p >= 0 && $ur->p >= 0) { if ($ur->p > $ul->p) { $revised_order->push($ul); $at_l++; continue; } } else { if ($ur->l > $ul->l) { $revised_order->push($ul); $at_l++; continue; } } $revised_order->push($ur); $at_r++; continue; unset($ur, $ul); } if ($at_r < $remotes->length) { $ur1 = $order[$remotes[$at_r]]; $revised_order->push($ur1); $at_r++; continue; unset($ur1); } if ($at_l < $locals->length) { $ul1 = $order[$locals[$at_l]]; $revised_order->push($ul1); $at_l++; continue; unset($ul1); } unset($o4); } $order = $revised_order; $result = new coopy_Ordering(); $result->setList($order); if ($this->reference === null) { $result->ignoreParent(); } return $result; }