Array-Lock
view release on metacpan or search on metacpan
=item lock_indexes
=item unlock_indexxes
lock_indexes(@array);
Restricts the given arrays indexes to its current amount. No more indexes
can be added; however, the values of current indexes can be changed.
exists() will still work, but delete() will not, as its standard behavior
is to get rid of the current index. B<Note>: the current implementation prevents
bless()ing while locked. Any attempt to do so will raise an exception. Of course
you can still bless() the array before you call lock_indexes() so this shouldn't be
a problem.
Right now, lock_indexes does not function with a range. However, if I get feedback that
sugests that a range is desired, a hack of some sort may be possible.
unlock_indexes(@array);
Removes the restriction on the array's indexes.
=item lock_value
=item unlock_value
lock_values (@array, @indexes);
lock_values (@array);
unlock_values (@array, @indexes);
Locks and unlocks index value pairs in an array. If no set of indexes is
specified, then all current indexes are locked.
=cut
sub lock_values (\@;@) {
my($array,@indexes) = @_;
Internals::SvREADONLY $array->[$_], 1 for @indexes ? @indexes : $[.. $#{$array};
}
sub unlock_values (\@;@) {
my($array,@indexes) = @_;
( run in 0.505 second using v1.01-cache-2.11-cpan-49f99fa48dc )