[LON-CAPA-cvs] cvs: loncom /types Queue.pm Stack.pm
foxr
lon-capa-cvs@mail.lon-capa.org
Thu, 24 Apr 2003 10:57:57 -0000
foxr Thu Apr 24 06:57:57 2003 EDT
Modified files:
/loncom/types Queue.pm Stack.pm
Log:
Added Count member to fetch the number of elements in the data structure.
Index: loncom/types/Queue.pm
diff -u loncom/types/Queue.pm:1.2 loncom/types/Queue.pm:1.3
--- loncom/types/Queue.pm:1.2 Fri Apr 18 02:10:47 2003
+++ loncom/types/Queue.pm Thu Apr 24 06:57:57 2003
@@ -1,6 +1,6 @@
# Implement a simple queue in terms of a list.
#
-# $Id: Queue.pm,v 1.2 2003/04/18 06:10:47 albertel Exp $
+# $Id: Queue.pm,v 1.3 2003/04/24 10:57:57 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -85,6 +85,19 @@
return shift @$self; # Remove from the front of the queue.
}
+
+=pod
+=head1 Count
+
+Returns number of items in a queue.
+
+=cut
+
+sub Count {
+ my $self = shift;
+ my $count = scalar(@$self);
+ return $count;
+}
1;
Index: loncom/types/Stack.pm
diff -u loncom/types/Stack.pm:1.2 loncom/types/Stack.pm:1.3
--- loncom/types/Stack.pm:1.2 Fri Apr 18 02:10:47 2003
+++ loncom/types/Stack.pm Thu Apr 24 06:57:57 2003
@@ -1,6 +1,6 @@
# Implement a simple stack in terms of a list.
#
-# $Id: Stack.pm,v 1.2 2003/04/18 06:10:47 albertel Exp $
+# $Id: Stack.pm,v 1.3 2003/04/24 10:57:57 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -88,6 +88,16 @@
return pop(@$self);
}
+=pod
+=head 1
+ Returns the number of items on the stack.
+
+=cut
+sub Count {
+ my $self = shift;
+ my $elements = scalar(@$self);
+ return $elements;
+}
1;