Commits

Toby Inkster committed d5e44c9

Implementations of SHIFT and SPLICE.

  • Participants
  • Parent commits 253a21e

Comments (0)

Files changed (2)

 say $obj->{'bar'}->can('count');
 say $obj->{'baz'}[4]->nodePath;
 say join ',', sort $obj->{'bar'}->parentNode->keys;
-print Dumper($obj);
+#print Dumper($obj);
+

File lib/JSON/JOM/Array.pm

 	}
 }
 
+sub SPLICE
+{
+	my $ob  = shift;
+	my $sz  = $ob->FETCHSIZE;
+	my $off = @_ ? shift : 0;
+	$off   += $sz if $off < 0;
+	my $len = @_ ? shift : $sz-$off;
+	my @rv = splice(@$ob,$off,$len,@_);
+	
+	for (my $i=0; $i < scalar @$ob; $i++)
+	{
+		if (Scalar::Util::blessed($ob->[$i]) && $ob->[$i]->can('nodeIndex'))
+		{
+			$ob->[$i]->nodeIndex($i);
+		}
+	}
+	
+	return @rv;
+}
+
+sub SHIFT
+{
+	my $this = shift;
+	my $x = shift @$this;
+
+	for (my $i=0; $i < scalar @$this; $i++)
+	{
+		if (Scalar::Util::blessed($this->[$i]) && $this->[$i]->can('nodeIndex'))
+		{
+			$this->[$i]->nodeIndex($i);
+		}
+	}
+	
+	return $x;
+}
+
 1;