[LON-CAPA-cvs] cvs: newloncapa /types HashIterator.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 10 Apr 2003 14:27:00 -0000


albertel		Thu Apr 10 10:27:00 2003 EDT

  Modified files:              
    /newloncapa/types	HashIterator.pm 
  Log:
  - correcting pod
  
  
Index: newloncapa/types/HashIterator.pm
diff -u newloncapa/types/HashIterator.pm:1.2 newloncapa/types/HashIterator.pm:1.3
--- newloncapa/types/HashIterator.pm:1.2	Wed Apr  9 21:56:23 2003
+++ newloncapa/types/HashIterator.pm	Thu Apr 10 10:27:00 2003
@@ -1,18 +1,22 @@
 #
 #  Implement iteration over a opaque hash.
 #
+
 =pod
+
 =head1 HashIterator
-  A hash iterator is an object that alows iteration over a hash in
-  a manner analagous to the way that STL iterators allow iteration over those
-  containers.  The HashIterator has the effect of hiding the existence of the
-  hash from the caller and instead presenting an iteratable collection to
-  the caller.
-
-  The intent is for a hash iterator to be an object returned by another 
-  object or class to support iteration over some internal hash maintained 
-  by the object. Passing the hash itself back breaks data hiding and 
-  protection.
+
+A hash iterator is an object that alows iteration over a hash in a
+manner analagous to the way that STL iterators allow iteration over
+those containers.  The HashIterator has the effect of hiding the
+existence of the hash from the caller and instead presenting an
+iteratable collection to the caller.
+
+The intent is for a hash iterator to be an object returned by another
+object or class to support iteration over some internal hash
+maintained by the object. Passing the hash itself back breaks data
+hiding and protection.
+
 =head1 Typical usage:
 
     use HashIterator;
@@ -31,29 +35,39 @@
 
 =head1 Member Functions:
 
-=cut 
+=cut
 
 package HashIterator;
 
 =pod
+
 =head2 new(hash)
 
-   Create a new HashIterator object and return a reference to it.
-   Data members of the HashIterator include:
+Create a new HashIterator object and return a reference to it.  Data
+members of the HashIterator include:
+
+=over 4
 
 =item Hash
 
-     Reference to the hash being iterated over.
+Reference to the hash being iterated over.
+
 =item Keylist
 
-     The set of keys in the underlying hash (an anonymous array ref).
+The set of keys in the underlying hash (an anonymous array ref).
+
 =item KeyCount
 
-     The number of keys in the underlying hash.
+The number of keys in the underlying hash.
+
 =item Index
 
-     Position of the iterator within the keylist/hash table.
+Position of the iterator within the keylist/hash table.
+
+=back
+
 =cut
+
 sub new {
     my $class   = shift;	# Class name...
     my $hashref = shift;        # Maintain this hash.
@@ -74,9 +88,13 @@
 }
 
 =pod
+
 =head2 begin
-   Reset the iterator to the start of iteration.
+
+Reset the iterator to the start of iteration.
+
 =cut
+
 sub begin {
     my $self  = shift;		# Get object...
     $self->{Index} = 0;
@@ -84,20 +102,29 @@
 }
 
 =pod
+
 =head2 end
-   Return true if the iterator is off the end of the hash.
+
+Return true if the iterator is off the end of the hash.
+
 =cut
+
 sub end {
     my $self = shift;		# Retrieve self as object.
     return ($self->{Index}  >= $self->{KeyCount});
 }
+
 =pod
+
 =head2 get
-   Return the contents of the hash at the current key.  If
-   the key is off the end of the hash, undef is returned.
-   What is returned is a copy of the element.
-   If the index is off the end of the iteration, undef is returned.
+
+Return the contents of the hash at the current key.  If the key is off
+the end of the hash, undef is returned.  What is returned is a copy of
+the element.  If the index is off the end of the iteration, undef is
+returned.
+
 =cut
+
 sub get {
     my $self = shift;
     if ($self->end()) {
@@ -109,10 +136,15 @@
     my $key     = $keys[$self->{Index}];
     return $$hashref{$key};
 }
+
 =pod
+
 =head2 next
-    Advances the iterator.
+
+Advances the iterator.
+
 =cut
+
 sub next {
     my $self = shift;		# Get us.
     $self->{Index}  = $self->{Index} + 1;