Set::Scalar::Virtual - internal class for Set::Scalar


Set-Scalar documentation Contained in the Set-Scalar distribution.

Index


Code Index:

NAME

Top

Set::Scalar::Virtual - internal class for Set::Scalar

SYNOPSIS

Top

Internal use only.

DESCRIPTION

Top

This is not the module you are looking for. See the Set::Scalar.

AUTHOR

Top

Jarkko Hietaniemi <jhi@iki.fi>


Set-Scalar documentation Contained in the Set-Scalar distribution.

package Set::Scalar::Virtual;

use strict;
local $^W = 1;

use vars qw(@ISA);

@ISA = qw(Set::Scalar::Base);

use Set::Scalar::Base qw(_make_elements as_string _compare _strval);

use overload
    '""'	=> \&as_string,
    'eq'	=> \&are_equal,
    '=='	=> \&are_equal;

sub ELEMENT_SEPARATOR { " " }

sub _extend {
    my $self     = shift;
    my $elements = shift;

    $self->_insert_elements( $elements );
}

sub extend {
    my $self     = shift;

    $self->_extend( { _make_elements( @_ ) } );
}

sub compare {
    my $a = shift;
    my $b = shift;

    if (ref $a && ref $b && $a->isa(__PACKAGE__) && $b->isa(__PACKAGE__)) {
	$a = _strval($a);
	$b = _strval($b);
    }

    return _compare($a, $b);
}

sub are_equal {
    my $a = shift;
    my $b = shift;

    return $a->compare($b) eq 'equal';
}

sub clone {
    my $self     = shift;

    return $self;
}

1;