Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- function writeArray($arrSeg)
- {
- print "===\n";
- print get_class($arrSeg)."\n";
- print ":\tArrIdx\toffset\tvalue\n";
- print ":\t------\t------\t------\n";
- foreach($arrSeg as $k => $v)
- print ":\t".$arrSeg->peek($k)."\t".$k."\t".$v."\n";
- }
- function writeSeg($arrSeg)
- {
- print "===\n";
- print get_class($arrSeg).sprintf(' [start-index: %d|length: %d|last-index: %d]'."\n",
- $arrSeg->getStart(),
- $arrSeg->getLength(),
- $arrSeg->getLast());
- print ":\tOffset\tSegIdx\tvalue\n";
- print ":\t------\t------\t------\n";
- foreach($arrSeg as $k => $v)
- print ":\t".$arrSeg->getReference()->peek($k)."\t".$k."\t".$v."\n";
- }
- $a = new TAssoc(["The" => "quick", "brown" => "fox", "jumps" => "over", "the" => "lazy", "dog" => '.']);
- $b = new TAssocSegment($a, 6, 5); //"the", "lazy", "dog"
- $c = new TAssocSegment($a, NULL, 5); //"The", "quick", "brown", "fox", "jumps"
- $d = new TAssocSegment($a, 1, NULL); //"brown", "fox", "jumps", "over", "the"
- $e = new TAssocSegment($a, 2, 1); //"brown", "fox", "jumps", "over", "the", "lazy", "dog"
- $m = new TArray(["The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog", '.']);
- $n = new TArraySegment($m, 6, 5); //"the", "lazy", "dog"
- $o = new TArraySegment($m, NULL, 5); //"The", "quick", "brown", "fox", "jumps"
- $p = new TArraySegment($m, 1, NULL); //"brown", "fox", "jumps", "over", "the"
- $q = new TArraySegment($m, 2, 1); //"brown", "fox", "jumps", "over", "the", "lazy", "dog"
- print "\n\nDefaults\n";
- writeArray($a); //"The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"
- writeArray($m);
- print "\n\nTAssocSegment\n";
- writeSeg($b);
- writeSeg($c);
- writeSeg($d);
- writeSeg($e); //"the", "lazy", "dog"
- print "\n\nTArraySegment\n";
- writeSeg($n);
- writeSeg($o);
- writeSeg($p);
- writeSeg($q);
- ?>
- Defaults
- ===
- ILLI\System\Collection\TAssoc
- : ArrIdx offset value
- : ------ ------ ------
- : 0 The quick
- : 1 brown fox
- : 2 jumps over
- : 3 the lazy
- : 4 dog .
- ===
- ILLI\System\Collection\TArray
- : ArrIdx offset value
- : ------ ------ ------
- : 0 0 The
- : 1 1 quick
- : 2 2 brown
- : 3 3 fox
- : 4 4 jumps
- : 5 5 over
- : 6 6 the
- : 7 7 lazy
- : 8 8 dog
- : 9 9 .
- TAssocSegment
- ===
- ILLI\System\Collection\TAssocSegment [start-index: 4|length: 5|last-index: 4]
- : Offset SegIdx value
- : ------ ------ ------
- : dog 4 dog
- ===
- ILLI\System\Collection\TAssocSegment [start-index: 0|length: 5|last-index: 4]
- : Offset SegIdx value
- : ------ ------ ------
- : The 0 The
- : brown 1 brown
- : jumps 2 jumps
- : the 3 the
- : dog 4 dog
- ===
- ILLI\System\Collection\TAssocSegment [start-index: 1|length: 0|last-index: 4]
- : Offset SegIdx value
- : ------ ------ ------
- : brown 1 brown
- : jumps 2 jumps
- : the 3 the
- : dog 4 dog
- ===
- ILLI\System\Collection\TAssocSegment [start-index: 2|length: 1|last-index: 2]
- : Offset SegIdx value
- : ------ ------ ------
- : jumps 2 jumps
- : the 3 the
- : dog 4 dog
- TArraySegment
- ===
- ILLI\System\Collection\TArraySegment [start-index: 6|length: 5|last-index: 9]
- : Offset SegIdx value
- : ------ ------ ------
- : 6 6 the
- : 7 7 lazy
- : 8 8 dog
- : 9 9 .
- ===
- ILLI\System\Collection\TArraySegment [start-index: 0|length: 5|last-index: 4]
- : Offset SegIdx value
- : ------ ------ ------
- : 0 0 The
- : 1 1 quick
- : 2 2 brown
- : 3 3 fox
- : 4 4 jumps
- ===
- ILLI\System\Collection\TArraySegment [start-index: 1|length: 0|last-index: 9]
- : Offset SegIdx value
- : ------ ------ ------
- : 1 1 quick
- : 2 2 brown
- : 3 3 fox
- : 4 4 jumps
- : 5 5 over
- : 6 6 the
- : 7 7 lazy
- : 8 8 dog
- : 9 9 .
- ===
- ILLI\System\Collection\TArraySegment [start-index: 2|length: 1|last-index: 2]
- : Offset SegIdx value
- : ------ ------ ------
- : 2 2 brown
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement