Net-IPAddress-Util

 view release on metacpan or  search on metacpan

lib/Net/IPAddress/Util/Collection/Tie.pm  view on Meta::CPAN

package Net::IPAddress::Util::Collection::Tie;

use strict;
use warnings;
use 5.012;

use Carp qw( confess );

require Net::IPAddress::Util;

sub new {
  my $class = shift;
  $class = ref($class) || $class;
  my ($arg_ref) = @_;
  return bless $arg_ref => $class;
}

sub TIEARRAY {
  my ($class, $contents) = @_;
  $contents = [] unless defined $contents;
  @{$contents} = map { _checktype($_) } @{$contents};
  my $self = $class->new({ contents => $contents });
}

sub FETCH {
  my ($self, $i) = @_;
  return $self->{ contents }->[ $i ];
}

sub STORE {
  my ($self, $i, $v) = @_;
  $self->{ contents }->[ $i ] = _checktype($v);
  return $v;
}

sub FETCHSIZE {
  my ($self) = @_;
  return scalar @{$self->{ contents }};
}

sub EXISTS {
  my ($self, $i) = @_;
  return exists $self->{ contents }->[ $i ];
}

sub DELETE {
  my ($self, $i) = @_;
  return delete $self->{ contents }->[ $i ];
}

sub CLEAR {
  my ($self) = @_;
  $self->{ contents } = [ ];
  return $self->{ contents };
}

sub PUSH {
  my ($self, @l) = @_;
  push @{$self->{ contents }}, map { _checktype($_) } @l;
}

sub POP {
  my ($self) = @_;
  return pop @{$self->{ contents }};
}

sub UNSHIFT {
  my ($self, @l) = @_;
  unshift @{$self->{ contents }}, map { _checktype($_) } @l;
}

sub SHIFT {
  my ($self) = @_;
  return shift @{$self->{ contents }};
}

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.749 second using v1.00-cache-2.02-grep-82fe00e-cpan-9e6bc14194b6 )