$VERSION
=
'0.01'
;
sub
TIEHASH {
my
(
$class
,
$id
,
%hash
) =
@_
;
my
$storage
= {};
my
$obj
=
bless
[
$id
,
$storage
],
$class
;
for
my
$key
(
keys
%hash
) {
$storage
->{
$key
} =
$hash
{
$key
};
}
return
$obj
;
}
sub
keycount {
my
$self
=
shift
;
return
scalar
keys
%{
$self
->[1]};
}
sub
STORE {
my
(
$self
,
$key
,
$val
) =
@_
;
Yote::ObjProvider::dirty(
$self
->[2],
$self
->[0] );
$self
->[1]{
$key
} = Yote::ObjProvider::xform_in(
$val
);
}
sub
FIRSTKEY {
my
$self
=
shift
;
my
$a
=
scalar
keys
%{
$self
->[1]};
my
(
$k
,
$val
) =
each
%{
$self
->[1]};
return
wantarray
? (
$k
=>
$val
) :
$k
;
}
sub
NEXTKEY {
my
$self
=
shift
;
my
(
$k
,
$val
) =
each
%{
$self
->[1]};
return
wantarray
? (
$k
=>
$val
) :
$k
;
}
sub
FETCH {
my
(
$self
,
$key
) =
@_
;
return
Yote::ObjProvider::xform_out(
$self
->[1]{
$key
} );
}
sub
EXISTS {
my
(
$self
,
$key
) =
@_
;
return
defined
(
$self
->[1]{
$key
} );
}
sub
DELETE {
my
(
$self
,
$key
) =
@_
;
Yote::ObjProvider::dirty(
$self
->[2],
$self
->[0]);
return
delete
$self
->[1]{
$key
};
}
sub
CLEAR {
my
$self
=
shift
;
Yote::ObjProvider::dirty(
$self
->[2],
$self
->[0] );
%{
$self
->[1]} = ();
}
1;