diff Tree/Interval/Node/Constants.pm @ 0:acc8d8bfeb9a

Uploaded
author jjohnson
date Wed, 08 Feb 2012 16:59:24 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Tree/Interval/Node/Constants.pm	Wed Feb 08 16:59:24 2012 -0500
@@ -0,0 +1,32 @@
+package Tree::Interval::Node::Constants;
+
+use strict;
+use Carp;
+use vars qw( $VERSION @EXPORT );
+
+$VERSION = '0.1';
+
+require Exporter;
+*import = \&Exporter::import;
+
+my @Node_slots;
+my @Node_colors;
+
+BEGIN { 
+    @Node_slots  = qw(PARENT LEFT RIGHT COLOR KEY VAL MAX INTERVAL); 
+    @Node_colors = qw(RED BLACK);
+}
+
+@EXPORT = (@Node_colors, map {"_$_"} @Node_slots);
+
+use enum @Node_colors;
+use enum @Node_slots;
+
+# enum doesn't allow symbols to start with "_", but we want them 
+foreach my $s (@Node_slots) {
+    no strict 'refs';
+    *{"_$s"} = \&$s;
+    delete $Tree::RB::Node::Constants::{$s};
+} 
+
+1;