Build.PL100644001750001750 45513166153713 13610 0ustar00arunarun000000000000Tree-RB-0.500006# ========================================================================= # THIS FILE IS AUTOMATICALLY GENERATED BY MINILLA. # DO NOT EDIT DIRECTLY. # ========================================================================= use 5.008_001; use strict; use Module::Build::Tiny 0.035; Build_PL(); Changes100644001750001750 305313166153713 13624 0ustar00arunarun000000000000Tree-RB-0.500006Revision history for Tree-RB 0.500006 2017-10-07T13:33:58Z Make "put with non existing key" work as documented. 0.500005 07 January 2014 Changed version format to not be a dev release. 0.500_005 07 January 2014 Added nth() method. Fixed issue tracker link. 0.500_004 15 September 2013 Documentation fixes: http://rt.cpan.org/Public/Bug/Display.html?id=56453 http://rt.cpan.org/Public/Bug/Display.html?id=86636 0.500_003 22 November 2009 Fixed http://rt.cpan.org/Public/Bug/Display.html?id=49078 0.500_002 15 July 2009 Fixed http://rt.cpan.org/Public/Bug/Display.html?id=47894 Moved to Module::Install 0.500_001 10 June 2009 Changes in distribution packaging to include repository URL No code changes. 0.5 15 November 2008 16:43 Allow false values to be stored (thanks to Anton Petrusevich for pointing out the problem). Skip test of tied hash SCALAR method if we're not running at least 5.8.3 0.4 13 August 2008 10:15 No code changes, just fixed Build.PL to include dependency on enum. Happy birthday Jyothi! 0.3 09 August 2008 19:47 Tree iteration is now seekable. Hash iteration is now seekable and reversible. Use enum as it leads to more natural syntax than constant. 0.2 02 August 2008 12:57 Changes to work with older Perls: * 'use vars' instead of 'our' * Manually pull in &Exporter::import * Added a comment crediting java.util.TreeMap for balancing helper functions. 0.1 01 January 2008 20:05 Initial release. LICENSE100644001750001750 4377613166153713 13376 0ustar00arunarun000000000000Tree-RB-0.500006This software is copyright (c) 2017 by Arun Prasad C<< >> . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2017 by Arun Prasad C<< >> . This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2017 by Arun Prasad C<< >> . This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End META.json100644001750001750 407213166153713 13754 0ustar00arunarun000000000000Tree-RB-0.500006{ "abstract" : "Perl implementation of the Red/Black tree, a type of balanced binary search tree. ", "author" : [ "Arun Prasad C<< >>" ], "dynamic_config" : 0, "generated_by" : "Minilla/v3.0.13", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Tree-RB", "no_index" : { "directory" : [ "t", "xt", "inc", "share", "eg", "examples", "author", "builder" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "6.36", "Test::More" : "0.42" } }, "configure" : { "requires" : { "Module::Build::Tiny" : "0.035" } }, "develop" : { "requires" : { "Test::CPAN::Meta" : "0", "Test::MinimumVersion::Fast" : "0.04", "Test::PAUSE::Permissions" : "0.04", "Test::Pod" : "1.41", "Test::Spellunker" : "v0.2.7" } }, "runtime" : { "requires" : { "enum" : "0" } } }, "provides" : { "Tree::RB" : { "file" : "lib/Tree/RB.pm", "version" : "0.500006" }, "Tree::RB::Node" : { "file" : "lib/Tree/RB/Node.pm", "version" : "0.500006" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/arunbear/Tree-RB/issues" }, "homepage" : "https://github.com/arunbear/Tree-RB", "repository" : { "url" : "git://github.com/arunbear/Tree-RB.git", "web" : "https://github.com/arunbear/Tree-RB" } }, "version" : "0.500006", "x_authority" : "cpan:ARUNBEAR", "x_contributors" : [ "Arun Prasaad ", "Arun Prasaad ", "Arun Prasaad " ], "x_serialization_backend" : "JSON::PP version 2.27300" } Makefile100644001750001750 5724513166153713 14025 0ustar00arunarun000000000000Tree-RB-0.500006# This Makefile is for the Tree::RB extension to perl. # # It was generated automatically by MakeMaker version # 7.04 (Revision: 70400) from the contents of # Makefile.PL. Don't edit this file, edit Makefile.PL instead. # # ANY CHANGES MADE HERE WILL BE LOST! # # MakeMaker ARGV: () # # MakeMaker Parameters: # ABSTRACT => q[Perl implementation of the Red/Black tree, a type of balanced binary search tree. ] # AUTHOR => [q[Arun Prasad C<< >> ]] # BUILD_REQUIRES => { ExtUtils::MakeMaker=>q[6.36], Test::More=>q[0.42] } # CONFIGURE_REQUIRES => { } # DISTNAME => q[Tree-RB] # LICENSE => q[perl] # NAME => q[Tree::RB] # NO_META => q[1] # PREREQ_PM => { ExtUtils::MakeMaker=>q[6.36], Test::More=>q[0.42], enum=>q[0] } # TEST_REQUIRES => { } # VERSION => q[0.500005] # VERSION_FROM => q[lib/Tree/RB.pm] # dist => { PREOP=>q[$(PERL) -I. "-MModule::Install::Admin" -e "dist_preop(q($(DISTVNAME)))"] } # realclean => { FILES=>q[MYMETA.yml] } # --- MakeMaker post_initialize section: # --- MakeMaker const_config section: # These definitions are from config.sh (via /usr/lib64/perl5/Config.pm). # They may have been overridden via Makefile.PL or on the command line. AR = ar CC = gcc CCCDLFLAGS = -fPIC CCDLFLAGS = -Wl,--enable-new-dtags -Wl,-z,relro DLEXT = so DLSRC = dl_dlopen.xs EXE_EXT = FULL_AR = /usr/bin/ar LD = gcc LDDLFLAGS = -shared -Wl,-z,relro -L/usr/local/lib -fstack-protector-strong LDFLAGS = -Wl,-z,relro -fstack-protector-strong -L/usr/local/lib LIBC = libc-2.22.so LIB_EXT = .a OBJ_EXT = .o OSNAME = linux OSVERS = 4.7.9-200.fc24.x86_64 RANLIB = : SITELIBEXP = /usr/local/share/perl5 SITEARCHEXP = /usr/local/lib64/perl5 SO = so VENDORARCHEXP = /usr/lib64/perl5/vendor_perl VENDORLIBEXP = /usr/share/perl5/vendor_perl # --- MakeMaker constants section: AR_STATIC_ARGS = cr DIRFILESEP = / DFSEP = $(DIRFILESEP) NAME = Tree::RB NAME_SYM = Tree_RB VERSION = 0.500005 VERSION_MACRO = VERSION VERSION_SYM = 0_500005 DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\" XS_VERSION = 0.500005 XS_VERSION_MACRO = XS_VERSION XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\" INST_ARCHLIB = blib/arch INST_SCRIPT = blib/script INST_BIN = blib/bin INST_LIB = blib/lib INST_MAN1DIR = blib/man1 INST_MAN3DIR = blib/man3 MAN1EXT = 1 MAN3EXT = 3pm INSTALLDIRS = site DESTDIR = PREFIX = $(SITEPREFIX) PERLPREFIX = /usr SITEPREFIX = /usr/local VENDORPREFIX = /usr INSTALLPRIVLIB = /usr/share/perl5 DESTINSTALLPRIVLIB = $(DESTDIR)$(INSTALLPRIVLIB) INSTALLSITELIB = /usr/local/share/perl5 DESTINSTALLSITELIB = $(DESTDIR)$(INSTALLSITELIB) INSTALLVENDORLIB = /usr/share/perl5/vendor_perl DESTINSTALLVENDORLIB = $(DESTDIR)$(INSTALLVENDORLIB) INSTALLARCHLIB = /usr/lib64/perl5 DESTINSTALLARCHLIB = $(DESTDIR)$(INSTALLARCHLIB) INSTALLSITEARCH = /usr/local/lib64/perl5 DESTINSTALLSITEARCH = $(DESTDIR)$(INSTALLSITEARCH) INSTALLVENDORARCH = /usr/lib64/perl5/vendor_perl DESTINSTALLVENDORARCH = $(DESTDIR)$(INSTALLVENDORARCH) INSTALLBIN = /usr/bin DESTINSTALLBIN = $(DESTDIR)$(INSTALLBIN) INSTALLSITEBIN = /usr/local/bin DESTINSTALLSITEBIN = $(DESTDIR)$(INSTALLSITEBIN) INSTALLVENDORBIN = /usr/bin DESTINSTALLVENDORBIN = $(DESTDIR)$(INSTALLVENDORBIN) INSTALLSCRIPT = /usr/bin DESTINSTALLSCRIPT = $(DESTDIR)$(INSTALLSCRIPT) INSTALLSITESCRIPT = /usr/local/bin DESTINSTALLSITESCRIPT = $(DESTDIR)$(INSTALLSITESCRIPT) INSTALLVENDORSCRIPT = /usr/bin DESTINSTALLVENDORSCRIPT = $(DESTDIR)$(INSTALLVENDORSCRIPT) INSTALLMAN1DIR = /usr/share/man/man1 DESTINSTALLMAN1DIR = $(DESTDIR)$(INSTALLMAN1DIR) INSTALLSITEMAN1DIR = /usr/local/share/man/man1 DESTINSTALLSITEMAN1DIR = $(DESTDIR)$(INSTALLSITEMAN1DIR) INSTALLVENDORMAN1DIR = /usr/share/man/man1 DESTINSTALLVENDORMAN1DIR = $(DESTDIR)$(INSTALLVENDORMAN1DIR) INSTALLMAN3DIR = /usr/share/man/man3 DESTINSTALLMAN3DIR = $(DESTDIR)$(INSTALLMAN3DIR) INSTALLSITEMAN3DIR = /usr/local/share/man/man3 DESTINSTALLSITEMAN3DIR = $(DESTDIR)$(INSTALLSITEMAN3DIR) INSTALLVENDORMAN3DIR = /usr/share/man/man3 DESTINSTALLVENDORMAN3DIR = $(DESTDIR)$(INSTALLVENDORMAN3DIR) PERL_LIB = PERL_ARCHLIB = /usr/lib64/perl5 PERL_ARCHLIBDEP = /usr/lib64/perl5 LIBPERL_A = libperl.a FIRST_MAKEFILE = Makefile MAKEFILE_OLD = Makefile.old MAKE_APERL_FILE = Makefile.aperl PERLMAINCC = $(CC) PERL_INC = /usr/lib64/perl5/CORE PERL_INCDEP = /usr/lib64/perl5/CORE PERL = "/usr/bin/perl" "-Iinc" FULLPERL = "/usr/bin/perl" "-Iinc" ABSPERL = $(PERL) PERLRUN = $(PERL) FULLPERLRUN = $(FULLPERL) ABSPERLRUN = $(ABSPERL) PERLRUNINST = $(PERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" FULLPERLRUNINST = $(FULLPERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" ABSPERLRUNINST = $(ABSPERLRUN) "-I$(INST_ARCHLIB)" "-Iinc" "-I$(INST_LIB)" PERL_CORE = 0 PERM_DIR = 755 PERM_RW = 644 PERM_RWX = 755 MAKEMAKER = /usr/share/perl5/vendor_perl/ExtUtils/MakeMaker.pm MM_VERSION = 7.04 MM_REVISION = 70400 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) # DLBASE = Basename part of dynamic library. May be just equal BASEEXT. MAKE = make FULLEXT = Tree/RB BASEEXT = RB PARENT_NAME = Tree DLBASE = $(BASEEXT) VERSION_FROM = lib/Tree/RB.pm OBJECT = LDFROM = $(OBJECT) LINKTYPE = dynamic BOOTDEP = # Handy lists of source code files: XS_FILES = C_FILES = O_FILES = H_FILES = MAN1PODS = MAN3PODS = lib/Tree/RB.pm \ lib/Tree/RB/Node.pm \ lib/Tree/RB/Node/_Constants.pm # Where is the Config information that we are using/depend on CONFIGDEP = $(PERL_ARCHLIBDEP)$(DFSEP)Config.pm $(PERL_INCDEP)$(DFSEP)config.h # Where to build things INST_LIBDIR = $(INST_LIB)/Tree INST_ARCHLIBDIR = $(INST_ARCHLIB)/Tree INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT) INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT) INST_STATIC = INST_DYNAMIC = INST_BOOT = # Extra linker info EXPORT_LIST = PERL_ARCHIVE = PERL_ARCHIVEDEP = PERL_ARCHIVE_AFTER = TO_INST_PM = lib/Tree/RB.pm \ lib/Tree/RB/Node.pm \ lib/Tree/RB/Node/_Constants.pm PM_TO_BLIB = lib/Tree/RB.pm \ blib/lib/Tree/RB.pm \ lib/Tree/RB/Node.pm \ blib/lib/Tree/RB/Node.pm \ lib/Tree/RB/Node/_Constants.pm \ blib/lib/Tree/RB/Node/_Constants.pm # --- MakeMaker platform_constants section: MM_Unix_VERSION = 7.04 PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc # --- MakeMaker tool_autosplit section: # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto AUTOSPLITFILE = $(ABSPERLRUN) -e 'use AutoSplit; autosplit($$$$ARGV[0], $$$$ARGV[1], 0, 1, 1)' -- # --- MakeMaker tool_xsubpp section: # --- MakeMaker tools_other section: SHELL = /bin/sh CHMOD = chmod CP = cp MV = mv NOOP = $(TRUE) NOECHO = @ RM_F = rm -f RM_RF = rm -rf TEST_F = test -f TOUCH = touch UMASK_NULL = umask 0 DEV_NULL = > /dev/null 2>&1 MKPATH = $(ABSPERLRUN) -MExtUtils::Command -e 'mkpath' -- EQUALIZE_TIMESTAMP = $(ABSPERLRUN) -MExtUtils::Command -e 'eqtime' -- FALSE = false TRUE = true ECHO = echo ECHO_N = echo -n UNINST = 0 VERBINST = 0 MOD_INSTALL = $(ABSPERLRUN) -MExtUtils::Install -e 'install([ from_to => {@ARGV}, verbose => '\''$(VERBINST)'\'', uninstall_shadows => '\''$(UNINST)'\'', dir_mode => '\''$(PERM_DIR)'\'' ]);' -- DOC_INSTALL = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'perllocal_install' -- UNINSTALL = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'uninstall' -- WARN_IF_OLD_PACKLIST = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'warn_if_old_packlist' -- MACROSTART = MACROEND = USEMAKEFILE = -f FIXIN = $(ABSPERLRUN) -MExtUtils::MY -e 'MY->fixin(shift)' -- CP_NONEMPTY = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'cp_nonempty' -- # --- MakeMaker makemakerdflt section: makemakerdflt : all $(NOECHO) $(NOOP) # --- MakeMaker dist section: TAR = tar TARFLAGS = cvf ZIP = zip ZIPFLAGS = -r COMPRESS = gzip --best SUFFIX = .gz SHAR = shar PREOP = $(PERL) -I. "-MModule::Install::Admin" -e "dist_preop(q($(DISTVNAME)))" POSTOP = $(NOECHO) $(NOOP) TO_UNIX = $(NOECHO) $(NOOP) CI = ci -u RCS_LABEL = rcs -Nv$(VERSION_SYM): -q DIST_CP = best DIST_DEFAULT = tardist DISTNAME = Tree-RB DISTVNAME = Tree-RB-0.500005 # --- MakeMaker macro section: # --- MakeMaker depend section: # --- MakeMaker cflags section: # --- MakeMaker const_loadlibs section: # --- MakeMaker const_cccmd section: # --- MakeMaker post_constants section: # --- MakeMaker pasthru section: PASTHRU = LIBPERL_A="$(LIBPERL_A)"\ LINKTYPE="$(LINKTYPE)"\ PREFIX="$(PREFIX)" # --- MakeMaker special_targets section: .SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT) .PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir # --- MakeMaker c_o section: # --- MakeMaker xs_c section: # --- MakeMaker xs_o section: # --- MakeMaker top_targets section: all :: pure_all manifypods $(NOECHO) $(NOOP) pure_all :: config pm_to_blib subdirs linkext $(NOECHO) $(NOOP) subdirs :: $(MYEXTLIB) $(NOECHO) $(NOOP) config :: $(FIRST_MAKEFILE) blibdirs $(NOECHO) $(NOOP) help : perldoc ExtUtils::MakeMaker # --- MakeMaker blibdirs section: blibdirs : $(INST_LIBDIR)$(DFSEP).exists $(INST_ARCHLIB)$(DFSEP).exists $(INST_AUTODIR)$(DFSEP).exists $(INST_ARCHAUTODIR)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists $(INST_SCRIPT)$(DFSEP).exists $(INST_MAN1DIR)$(DFSEP).exists $(INST_MAN3DIR)$(DFSEP).exists $(NOECHO) $(NOOP) # Backwards compat with 6.18 through 6.25 blibdirs.ts : blibdirs $(NOECHO) $(NOOP) $(INST_LIBDIR)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_LIBDIR) $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_LIBDIR) $(NOECHO) $(TOUCH) $(INST_LIBDIR)$(DFSEP).exists $(INST_ARCHLIB)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_ARCHLIB) $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_ARCHLIB) $(NOECHO) $(TOUCH) $(INST_ARCHLIB)$(DFSEP).exists $(INST_AUTODIR)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_AUTODIR) $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_AUTODIR) $(NOECHO) $(TOUCH) $(INST_AUTODIR)$(DFSEP).exists $(INST_ARCHAUTODIR)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR) $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_ARCHAUTODIR) $(NOECHO) $(TOUCH) $(INST_ARCHAUTODIR)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_BIN) $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_BIN) $(NOECHO) $(TOUCH) $(INST_BIN)$(DFSEP).exists $(INST_SCRIPT)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_SCRIPT) $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_SCRIPT) $(NOECHO) $(TOUCH) $(INST_SCRIPT)$(DFSEP).exists $(INST_MAN1DIR)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_MAN1DIR) $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_MAN1DIR) $(NOECHO) $(TOUCH) $(INST_MAN1DIR)$(DFSEP).exists $(INST_MAN3DIR)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_MAN3DIR) $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_MAN3DIR) $(NOECHO) $(TOUCH) $(INST_MAN3DIR)$(DFSEP).exists # --- MakeMaker linkext section: linkext :: $(LINKTYPE) $(NOECHO) $(NOOP) # --- MakeMaker dlsyms section: # --- MakeMaker dynamic_bs section: BOOTSTRAP = # --- MakeMaker dynamic section: dynamic :: $(FIRST_MAKEFILE) $(BOOTSTRAP) $(INST_DYNAMIC) $(NOECHO) $(NOOP) # --- MakeMaker dynamic_lib section: # --- MakeMaker static section: ## $(INST_PM) has been moved to the all: target. ## It remains here for awhile to allow for old usage: "make static" static :: $(FIRST_MAKEFILE) $(INST_STATIC) $(NOECHO) $(NOOP) # --- MakeMaker static_lib section: # --- MakeMaker manifypods section: POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--" POD2MAN = $(POD2MAN_EXE) manifypods : pure_all \ lib/Tree/RB.pm \ lib/Tree/RB/Node.pm \ lib/Tree/RB/Node/_Constants.pm $(NOECHO) $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) -u \ lib/Tree/RB.pm $(INST_MAN3DIR)/Tree::RB.$(MAN3EXT) \ lib/Tree/RB/Node.pm $(INST_MAN3DIR)/Tree::RB::Node.$(MAN3EXT) \ lib/Tree/RB/Node/_Constants.pm $(INST_MAN3DIR)/Tree::RB::Node::_Constants.$(MAN3EXT) # --- MakeMaker processPL section: # --- MakeMaker installbin section: # --- MakeMaker subdirs section: # none # --- MakeMaker clean_subdirs section: clean_subdirs : $(NOECHO) $(NOOP) # --- MakeMaker clean section: # Delete temporary files but do not touch installed files. We don't delete # the Makefile here so a later make realclean still has a makefile to use. clean :: clean_subdirs - $(RM_F) \ $(BASEEXT).bso $(BASEEXT).def \ $(BASEEXT).exp $(BASEEXT).x \ $(BOOTSTRAP) $(INST_ARCHAUTODIR)/extralibs.all \ $(INST_ARCHAUTODIR)/extralibs.ld $(MAKE_APERL_FILE) \ *$(LIB_EXT) *$(OBJ_EXT) \ *perl.core MYMETA.json \ MYMETA.yml blibdirs.ts \ core core.*perl.*.? \ core.[0-9] core.[0-9][0-9] \ core.[0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9] \ core.[0-9][0-9][0-9][0-9][0-9] lib$(BASEEXT).def \ mon.out perl \ perl$(EXE_EXT) perl.exe \ perlmain.c pm_to_blib \ pm_to_blib.ts so_locations \ tmon.out - $(RM_RF) \ blib $(NOECHO) $(RM_F) $(MAKEFILE_OLD) - $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL) # --- MakeMaker realclean_subdirs section: realclean_subdirs : $(NOECHO) $(NOOP) # --- MakeMaker realclean section: # Delete temporary files (via clean) and also delete dist files realclean purge :: clean realclean_subdirs - $(RM_F) \ $(MAKEFILE_OLD) $(FIRST_MAKEFILE) - $(RM_RF) \ MYMETA.yml $(DISTVNAME) # --- MakeMaker metafile section: metafile : $(NOECHO) $(NOOP) # --- MakeMaker signature section: signature : cpansign -s # --- MakeMaker dist_basics section: distclean :: realclean distcheck $(NOECHO) $(NOOP) distcheck : $(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck skipcheck : $(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck manifest : $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest veryclean : realclean $(RM_F) *~ */*~ *.orig */*.orig *.bak */*.bak *.old */*.old # --- MakeMaker dist_core section: dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE) $(NOECHO) $(ABSPERLRUN) -l -e 'print '\''Warning: Makefile possibly out of date with $(VERSION_FROM)'\''' \ -e ' if -e '\''$(VERSION_FROM)'\'' and -M '\''$(VERSION_FROM)'\'' < -M '\''$(FIRST_MAKEFILE)'\'';' -- tardist : $(DISTVNAME).tar$(SUFFIX) $(NOECHO) $(NOOP) uutardist : $(DISTVNAME).tar$(SUFFIX) uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu $(NOECHO) $(ECHO) 'Created $(DISTVNAME).tar$(SUFFIX)_uu' $(DISTVNAME).tar$(SUFFIX) : distdir $(PREOP) $(TO_UNIX) $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME) $(RM_RF) $(DISTVNAME) $(COMPRESS) $(DISTVNAME).tar $(NOECHO) $(ECHO) 'Created $(DISTVNAME).tar$(SUFFIX)' $(POSTOP) zipdist : $(DISTVNAME).zip $(NOECHO) $(NOOP) $(DISTVNAME).zip : distdir $(PREOP) $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME) $(RM_RF) $(DISTVNAME) $(NOECHO) $(ECHO) 'Created $(DISTVNAME).zip' $(POSTOP) shdist : distdir $(PREOP) $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar $(RM_RF) $(DISTVNAME) $(NOECHO) $(ECHO) 'Created $(DISTVNAME).shar' $(POSTOP) # --- MakeMaker distdir section: create_distdir : $(RM_RF) $(DISTVNAME) $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \ -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');" distdir : create_distdir $(NOECHO) $(NOOP) # --- MakeMaker dist_test section: disttest : distdir cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL cd $(DISTVNAME) && $(MAKE) $(PASTHRU) cd $(DISTVNAME) && $(MAKE) test $(PASTHRU) # --- MakeMaker dist_ci section: ci : $(PERLRUN) "-MExtUtils::Manifest=maniread" \ -e "@all = keys %{ maniread() };" \ -e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \ -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});" # --- MakeMaker distmeta section: distmeta : create_distdir metafile $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'exit unless -e q{META.yml};' \ -e 'eval { maniadd({q{META.yml} => q{Module YAML meta-data (added by MakeMaker)}}) }' \ -e ' or print "Could not add META.yml to MANIFEST: $$$${'\''@'\''}\n"' -- $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'exit unless -f q{META.json};' \ -e 'eval { maniadd({q{META.json} => q{Module JSON meta-data (added by MakeMaker)}}) }' \ -e ' or print "Could not add META.json to MANIFEST: $$$${'\''@'\''}\n"' -- # --- MakeMaker distsignature section: distsignature : create_distdir $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) }' \ -e ' or print "Could not add SIGNATURE to MANIFEST: $$$${'\''@'\''}\n"' -- $(NOECHO) cd $(DISTVNAME) && $(TOUCH) SIGNATURE cd $(DISTVNAME) && cpansign -s # --- MakeMaker install section: install :: pure_install doc_install $(NOECHO) $(NOOP) install_perl :: pure_perl_install doc_perl_install $(NOECHO) $(NOOP) install_site :: pure_site_install doc_site_install $(NOECHO) $(NOOP) install_vendor :: pure_vendor_install doc_vendor_install $(NOECHO) $(NOOP) pure_install :: pure_$(INSTALLDIRS)_install $(NOECHO) $(NOOP) doc_install :: doc_$(INSTALLDIRS)_install $(NOECHO) $(NOOP) pure__install : pure_site_install $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site doc__install : doc_site_install $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site pure_perl_install :: all $(NOECHO) $(MOD_INSTALL) \ read "$(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist" \ write "$(DESTINSTALLARCHLIB)/auto/$(FULLEXT)/.packlist" \ "$(INST_LIB)" "$(DESTINSTALLPRIVLIB)" \ "$(INST_ARCHLIB)" "$(DESTINSTALLARCHLIB)" \ "$(INST_BIN)" "$(DESTINSTALLBIN)" \ "$(INST_SCRIPT)" "$(DESTINSTALLSCRIPT)" \ "$(INST_MAN1DIR)" "$(DESTINSTALLMAN1DIR)" \ "$(INST_MAN3DIR)" "$(DESTINSTALLMAN3DIR)" $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ "$(SITEARCHEXP)/auto/$(FULLEXT)" pure_site_install :: all $(NOECHO) $(MOD_INSTALL) \ read "$(SITEARCHEXP)/auto/$(FULLEXT)/.packlist" \ write "$(DESTINSTALLSITEARCH)/auto/$(FULLEXT)/.packlist" \ "$(INST_LIB)" "$(DESTINSTALLSITELIB)" \ "$(INST_ARCHLIB)" "$(DESTINSTALLSITEARCH)" \ "$(INST_BIN)" "$(DESTINSTALLSITEBIN)" \ "$(INST_SCRIPT)" "$(DESTINSTALLSITESCRIPT)" \ "$(INST_MAN1DIR)" "$(DESTINSTALLSITEMAN1DIR)" \ "$(INST_MAN3DIR)" "$(DESTINSTALLSITEMAN3DIR)" $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ "$(PERL_ARCHLIB)/auto/$(FULLEXT)" pure_vendor_install :: all $(NOECHO) $(MOD_INSTALL) \ read "$(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist" \ write "$(DESTINSTALLVENDORARCH)/auto/$(FULLEXT)/.packlist" \ "$(INST_LIB)" "$(DESTINSTALLVENDORLIB)" \ "$(INST_ARCHLIB)" "$(DESTINSTALLVENDORARCH)" \ "$(INST_BIN)" "$(DESTINSTALLVENDORBIN)" \ "$(INST_SCRIPT)" "$(DESTINSTALLVENDORSCRIPT)" \ "$(INST_MAN1DIR)" "$(DESTINSTALLVENDORMAN1DIR)" \ "$(INST_MAN3DIR)" "$(DESTINSTALLVENDORMAN3DIR)" doc_perl_install :: all $(NOECHO) $(ECHO) Appending installation info to "$(DESTINSTALLARCHLIB)/perllocal.pod" -$(NOECHO) $(MKPATH) "$(DESTINSTALLARCHLIB)" -$(NOECHO) $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" $(INSTALLPRIVLIB) \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ >> "$(DESTINSTALLARCHLIB)/perllocal.pod" doc_site_install :: all $(NOECHO) $(ECHO) Appending installation info to "$(DESTINSTALLARCHLIB)/perllocal.pod" -$(NOECHO) $(MKPATH) "$(DESTINSTALLARCHLIB)" -$(NOECHO) $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" $(INSTALLSITELIB) \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ >> "$(DESTINSTALLARCHLIB)/perllocal.pod" doc_vendor_install :: all $(NOECHO) $(ECHO) Appending installation info to "$(DESTINSTALLARCHLIB)/perllocal.pod" -$(NOECHO) $(MKPATH) "$(DESTINSTALLARCHLIB)" -$(NOECHO) $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" $(INSTALLVENDORLIB) \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ >> "$(DESTINSTALLARCHLIB)/perllocal.pod" uninstall :: uninstall_from_$(INSTALLDIRS)dirs $(NOECHO) $(NOOP) uninstall_from_perldirs :: $(NOECHO) $(UNINSTALL) "$(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist" uninstall_from_sitedirs :: $(NOECHO) $(UNINSTALL) "$(SITEARCHEXP)/auto/$(FULLEXT)/.packlist" uninstall_from_vendordirs :: $(NOECHO) $(UNINSTALL) "$(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist" # --- MakeMaker force section: # Phony target to force checking subdirectories. FORCE : $(NOECHO) $(NOOP) # --- MakeMaker perldepend section: # --- MakeMaker makefile section: # We take a very conservative approach here, but it's worth it. # We move Makefile to Makefile.old here to avoid gnu make looping. $(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?" $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..." -$(NOECHO) $(RM_F) $(MAKEFILE_OLD) -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL) $(PERLRUN) Makefile.PL $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <==" $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <==" $(FALSE) # --- MakeMaker staticmake section: # --- MakeMaker makeaperl section --- MAP_TARGET = perl FULLPERL = "/usr/bin/perl" $(MAP_TARGET) :: static $(MAKE_APERL_FILE) $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@ $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) $(NOECHO) $(PERLRUNINST) \ Makefile.PL DIR="" \ MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \ MAKEAPERL=1 NORECURS=1 CCCDLFLAGS= # --- MakeMaker test section: TEST_VERBOSE=0 TEST_TYPE=test_$(LINKTYPE) TEST_FILE = test.pl TEST_FILES = t/*.t TESTDB_SW = -d testdb :: testdb_$(LINKTYPE) test :: $(TEST_TYPE) subdirs-test subdirs-test :: $(NOECHO) $(NOOP) test_dynamic :: pure_all PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness($(TEST_VERBOSE), 'inc', '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES) testdb_dynamic :: pure_all PERL_DL_NONLAZY=1 $(FULLPERLRUN) $(TESTDB_SW) "-Iinc" "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE) test_ : test_dynamic test_static :: test_dynamic testdb_static :: testdb_dynamic # --- MakeMaker ppd section: # Creates a PPD (Perl Package Description) for a binary distribution. ppd : $(NOECHO) $(ECHO) '' > $(DISTNAME).ppd $(NOECHO) $(ECHO) ' Perl implementation of the Red/Black tree, a type of balanced binary search tree. ' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' Arun Prasad C<< <arunbear@cpan.org> >> ' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) '' >> $(DISTNAME).ppd # --- MakeMaker pm_to_blib section: pm_to_blib : $(FIRST_MAKEFILE) $(TO_INST_PM) $(NOECHO) $(ABSPERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', q[$(PM_FILTER)], '\''$(PERM_DIR)'\'')' -- \ lib/Tree/RB.pm blib/lib/Tree/RB.pm \ lib/Tree/RB/Node.pm blib/lib/Tree/RB/Node.pm \ lib/Tree/RB/Node/_Constants.pm blib/lib/Tree/RB/Node/_Constants.pm $(NOECHO) $(TOUCH) pm_to_blib # --- MakeMaker selfdocument section: # --- MakeMaker postamble section: # End. # Postamble by Module::Install 1.18 # --- Module::Install::Admin::Makefile section: realclean purge :: $(RM_F) $(DISTVNAME).tar$(SUFFIX) $(RM_F) MANIFEST.bak _build $(PERL) "-Ilib" "-MModule::Install::Admin" -e "remove_meta()" $(RM_RF) inc reset :: purge upload :: test dist cpan-upload -verbose $(DISTVNAME).tar$(SUFFIX) grok :: perldoc Module::Install distsign :: cpansign -s README.md100644001750001750 2352413166153713 13635 0ustar00arunarun000000000000Tree-RB-0.500006# NAME Tree::RB - Perl implementation of the Red/Black tree, a type of balanced binary search tree. # SYNOPSIS use Tree::RB; my $tree = Tree::RB->new; $tree->put('France' => 'Paris'); $tree->put('England' => 'London'); $tree->put('Hungary' => 'Budapest'); $tree->put('Ireland' => 'Dublin'); $tree->put('Egypt' => 'Cairo'); $tree->put('Germany' => 'Berlin'); $tree->put('Alaska' => 'Anchorage'); # D'oh! Alaska isn't a Country $tree->delete('Alaska'); print scalar $tree->get('Ireland'); # 'Dublin' print $tree->size; # 6 print $tree->min->key; # 'Egypt' print $tree->max->key; # 'Ireland' print $tree->nth(0)->key; # 'Egypt' print $tree->nth(-1)->key; # 'Ireland' # print items, ordered by key my $it = $tree->iter; while(my $node = $it->next) { printf "key = %s, value = %s\n", $node->key, $node->val; } # print items in reverse order $it = $tree->rev_iter; while(my $node = $it->next) { printf "key = %s, value = %s\n", $node->key, $node->val; } # Hash interface tie my %capital, 'Tree::RB'; # or do this to store items in descending order tie my %capital, 'Tree::RB', sub { $_[1] cmp $_[0] }; $capital{'France'} = 'Paris'; $capital{'England'} = 'London'; $capital{'Hungary'} = 'Budapest'; $capital{'Ireland'} = 'Dublin'; $capital{'Egypt'} = 'Cairo'; $capital{'Germany'} = 'Berlin'; # print items in order while(my ($key, $val) = each %capital) { printf "key = $key, value = $val\n"; } # DESCRIPTION This is a Perl implementation of the Red/Black tree, a type of balanced binary search tree. A tied hash interface is also provided to allow ordered hashes to be used. See the Wikipedia article at [http://en.wikipedia.org/wiki/Red-black\_tree](http://en.wikipedia.org/wiki/Red-black_tree) for further information about Red/Black trees. # INTERFACE ## new(\[CODEREF\]) Creates and returns a new tree. If a reference to a subroutine is passed to new(), the subroutine will be used to override the tree's default lexical ordering and provide a user a defined ordering. This subroutine should be just like a comparator subroutine used with [sort](https://metacpan.org/pod/sort), except that it doesn't do the $a, $b trick. For example, to get a case insensitive ordering my $tree = Tree::RB->new(sub { lc $_[0] cmp lc $_[1]}); $tree->put('Wall' => 'Larry'); $tree->put('Smith' => 'Agent'); $tree->put('mouse' => 'micky'); $tree->put('duck' => 'donald'); my $it = $tree->iter; while(my $node = $it->next) { printf "key = %s, value = %s\n", $node->key, $node->val; } ## resort(CODEREF) Changes the ordering of nodes within the tree. The new ordering is specified by a comparator subroutine which must be passed to resort(). See ["new"](#new) for further information about the comparator. ## size() Returns the number of nodes in the tree. ## root() Returns the root node of the tree. This will either be undef if no nodes have been added to the tree, or a [Tree::RB::Node](https://metacpan.org/pod/Tree::RB::Node) object. See the [Tree::RB::Node](https://metacpan.org/pod/Tree::RB::Node) manual page for details on the Node object. ## min() Returns the node with the minimal key. ## max() Returns the node with the maximal key. ## nth(INDEX) Returns the node at the given (zero based) index, or undef if there is no node at that index. Negative indexes can be used, with -1 indicating the last node, -2 the penultimate node and so on. ## lookup(KEY, \[MODE\]) When called in scalar context, lookup(KEY) returns the value associated with KEY. When called in list context, lookup(KEY) returns a list whose first element is the value associated with KEY, and whose second element is the node containing the key/value. An optional MODE parameter can be passed to lookup() to influence which key is returned. The values of MODE are constants that are exported on demand by Tree::RB use Tree::RB qw[LUEQUAL LUGTEQ LULTEQ LUGREAT LULESS LUNEXT LUPREV]; - LUEQUAL This is the default mode. Returns the node exactly matching the key, or `undef` if not found. - LUGTEQ Returns the node exactly matching the specified key, if this is not found then the next node that is greater than the specified key is returned. - LULTEQ Returns the node exactly matching the specified key, if this is not found then the next node that is less than the specified key is returned. - LUGREAT Returns the node that is just greater than the specified key - not equal to. This mode is similar to LUNEXT except that the specified key need not exist in the tree. - LULESS Returns the node that is just less than the specified key - not equal to. This mode is similar to LUPREV except that the specified key need not exist in the tree. - LUNEXT Looks for the key specified, if not found returns `undef`. If the node is found returns the next node that is greater than the one found (or `undef` if there is no next node). This can be used to step through the tree in order. - LUPREV Looks for the key specified, if not found returns `undef`. If the node is found returns the previous node that is less than the one found (or `undef` if there is no previous node). This can be used to step through the tree in reverse order. ## get(KEY) get() is an alias for lookup(). ## iter(\[KEY\]) Returns an iterator object that can be used to traverse the tree in order. The iterator object supports a 'next' method that returns the next node in the tree or undef if all of the nodes have been visited. See the synopsis for an example. If a key is supplied, the iterator returned will traverse the tree in order starting from the node with key greater than or equal to the specified key. $it = $tree->iter('France'); my $node = $it->next; print $node->key; # -> 'France' ## rev\_iter(\[KEY\]) Returns an iterator object that can be used to traverse the tree in reverse order. If a key is supplied, the iterator returned will traverse the tree in order starting from the node with key less than or equal to the specified key. $it = $tree->rev_iter('France'); my $node = $it->next; print $node->key; # -> 'France' $it = $tree->rev_iter('Finland'); my $node = $it->next; print $node->key; # -> 'England' ## hseek(KEY, \[{-reverse => 1|0}\]) For tied hashes, determines the next entry to be returned by each. tie my %capital, 'Tree::RB'; $capital{'France'} = 'Paris'; $capital{'England'} = 'London'; $capital{'Hungary'} = 'Budapest'; $capital{'Ireland'} = 'Dublin'; $capital{'Egypt'} = 'Cairo'; $capital{'Germany'} = 'Berlin'; tied(%capital)->hseek('Germany'); ($key, $val) = each %capital; print "$key, $val"; # -> Germany, Berlin The direction of iteration can be reversed by passing a hashref with key '-reverse' and value 1 to hseek after or instead of KEY, e.g. to iterate over the hash in reverse order: tied(%capital)->hseek({-reverse => 1}); $key = each %capital; print $key; # -> Ireland The following calls are equivalent tied(%capital)->hseek('Germany', {-reverse => 1}); tied(%capital)->hseek({-key => 'Germany', -reverse => 1}); ## put(KEY, VALUE) Adds a new node to the tree. The first argument is the key of the node, the second is its value. If a node with that key already exists, its value is replaced with the given value and the old value is returned. Otherwise, undef is returned. ## delete(KEY) If the tree has a node with the specified key, that node is deleted from the tree and returned, otherwise `undef` is returned. # DEPENDENCIES [enum](https://metacpan.org/pod/enum) # INCOMPATIBILITIES None reported. # BUGS AND LIMITATIONS Please report any bugs or feature requests via the GitHub web interface at [https://github.com/arunbear/perl5-red-black-tree/issues](https://github.com/arunbear/perl5-red-black-tree/issues). # AUTHOR Arun Prasad `` Some documentation has been borrowed from Benjamin Holzman's [Tree::RedBlack](https://metacpan.org/pod/Tree::RedBlack) and Damian Ivereigh's libredblack ([http://libredblack.sourceforge.net/](http://libredblack.sourceforge.net/)). # ACKNOWLEDGEMENTS Thanks for bug reports go to Anton Petrusevich, Wes Thompson, Petre Mierlutiu, Tomer Vromen, Christopher Gurnee and Ole Bjorn Hessen. # LICENCE AND COPYRIGHT Copyright (c) 2007, Arun Prasad ``. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See [perlartistic](https://metacpan.org/pod/perlartistic). # DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. cpanfile100644001750001750 16613166153713 14017 0ustar00arunarun000000000000Tree-RB-0.500006requires 'enum'; on build => sub { requires 'ExtUtils::MakeMaker', '6.36'; requires 'Test::More', '0.42'; }; RB.pm100644001750001750 5611213166153713 14663 0ustar00arunarun000000000000Tree-RB-0.500006/lib/Treepackage Tree::RB; use strict; use Carp; use Tree::RB::Node qw[set_color color_of parent_of left_of right_of]; use Tree::RB::Node::_Constants; use vars qw( $VERSION @EXPORT_OK ); $VERSION = '0.500006'; $VERSION = eval $VERSION; require Exporter; *import = \&Exporter::import; @EXPORT_OK = qw[LUEQUAL LUGTEQ LULTEQ LUGREAT LULESS LUNEXT LUPREV]; use enum qw{ LUEQUAL LUGTEQ LULTEQ LUGREAT LULESS LUNEXT LUPREV }; # object slots use enum qw{ ROOT CMP SIZE HASH_ITER HASH_SEEK_ARG }; # Node and hash Iteration sub _mk_iter { my $start_fn = shift || 'min'; my $next_fn = shift || 'successor'; return sub { my $self = shift; my $key = shift; my $node; my $iter = sub { if($node) { $node = $node->$next_fn; } else { if(defined $key) { # seek to $key (undef, $node) = $self->lookup( $key, $next_fn eq 'successor' ? LUGTEQ : LULTEQ ); } else { $node = $self->$start_fn; } } return $node; }; return bless($iter => 'Tree::RB::Iterator'); }; } *Tree::RB::Iterator::next = sub { $_[0]->() }; *iter = _mk_iter(qw/min successor/); *rev_iter = _mk_iter(qw/max predecessor/); sub hseek { my $self = shift; my $arg = shift; defined $arg or croak("Can't seek to an undefined key"); my %args; if(ref $arg eq 'HASH') { %args = %$arg; } else { $args{-key} = $arg; } if(@_ && exists $args{-key}) { my $arg = shift; if(ref $arg eq 'HASH') { %args = (%$arg, %args); } } if(! exists $args{-key}) { defined $args{'-reverse'} or croak("Expected option '-reverse' is undefined"); } $self->[HASH_SEEK_ARG] = \%args; if($self->[HASH_ITER]) { $self->_reset_hash_iter; } } sub _reset_hash_iter { my $self = shift; if($self->[HASH_SEEK_ARG]) { my $iter = ($self->[HASH_SEEK_ARG]{'-reverse'} ? 'rev_iter' : 'iter'); $self->[HASH_ITER] = $self->$iter($self->[HASH_SEEK_ARG]{'-key'}); } else { $self->[HASH_ITER] = $self->iter; } } sub FIRSTKEY { my $self = shift; $self->_reset_hash_iter; my $node = $self->[HASH_ITER]->next or return; return $node->[_KEY]; } sub NEXTKEY { my $self = shift; my $node = $self->[HASH_ITER]->next or return; return $node->[_KEY]; } sub new { my ($class, $cmp) = @_; my $obj = []; $obj->[SIZE] = 0; if($cmp) { ref $cmp eq 'CODE' or croak('Invalid arg: codref expected'); $obj->[CMP] = $cmp; } return bless $obj => $class; } *TIEHASH = \&new; sub DESTROY { $_[0]->[ROOT]->DESTROY if $_[0]->[ROOT] } sub CLEAR { my $self = shift; if($self->[ROOT]) { $self->[ROOT]->DESTROY; undef $self->[ROOT]; undef $self->[HASH_ITER]; $self->[SIZE] = 0; } } sub UNTIE { my $self = shift; $self->DESTROY; undef @$self; } sub resort { my $self = $_[0]; my $cmp = $_[1]; ref $cmp eq 'CODE' or croak sprintf(q[Arg of type coderef required; got %s], ref $cmp || 'undef'); my $new_tree = __PACKAGE__->new($cmp); $self->[ROOT]->strip(sub { $new_tree->put($_[0]) }); $new_tree->put(delete $self->[ROOT]); $_[0] = $new_tree; } sub root { $_[0]->[ROOT] } sub size { $_[0]->[SIZE] } *SCALAR = \&size; sub min { my $self = shift; return undef unless $self->[ROOT]; return $self->[ROOT]->min; } sub max { my $self = shift; return undef unless $self->[ROOT]; return $self->[ROOT]->max; } sub lookup { my $self = shift; my $key = shift; defined $key or croak("Can't use undefined value as key"); my $mode = shift || LUEQUAL; my $cmp = $self->[CMP]; my $y; my $x = $self->[ROOT] or return; my $next_child; while($x) { $y = $x; if($cmp ? $cmp->($key, $x->[_KEY]) == 0 : $key eq $x->[_KEY]) { # found it! if($mode == LUGREAT || $mode == LUNEXT) { $x = $x->successor; } elsif($mode == LULESS || $mode == LUPREV) { $x = $x->predecessor; } return wantarray ? ($x->[_VAL], $x) : $x->[_VAL]; } if($cmp ? $cmp->($key, $x->[_KEY]) < 0 : $key lt $x->[_KEY]) { $next_child = _LEFT; } else { $next_child = _RIGHT; } $x = $x->[$next_child]; } # Didn't find it :( if($mode == LUGTEQ || $mode == LUGREAT) { if($next_child == _LEFT) { return wantarray ? ($y->[_VAL], $y) : $y->[_VAL]; } else { my $next = $y->successor or return; return wantarray ? ($next->[_VAL], $next) : $next->[_VAL]; } } elsif($mode == LULTEQ || $mode == LULESS) { if($next_child == _RIGHT) { return wantarray ? ($y->[_VAL], $y) : $y->[_VAL]; } else { my $next = $y->predecessor or return; return wantarray ? ($next->[_VAL], $next) : $next->[_VAL]; } } return; } *FETCH = \&lookup; *get = \&lookup; sub nth { my ($self, $i) = @_; $i =~ /^-?\d+$/ or croak('Integer index expected'); if ($i < 0) { $i += $self->[SIZE]; } if ($i < 0 || $i >= $self->[SIZE]) { return; } my ($node, $next, $moves); if ($i > $self->[SIZE] / 2) { $node = $self->max; $next = 'predecessor'; $moves = $self->[SIZE] - $i - 1; } else { $node = $self->min; $next = 'successor'; $moves = $i; } my $count = 0; while ($count != $moves) { $node = $node->$next; ++$count; } return $node; } sub EXISTS { my $self = shift; my $key = shift; return defined $self->lookup($key); } sub put { my $self = shift; my $key_or_node = shift; defined $key_or_node or croak("Can't use undefined value as key or node"); my $val = shift; my $cmp = $self->[CMP]; my $z = (ref $key_or_node eq 'Tree::RB::Node') ? $key_or_node : Tree::RB::Node->new($key_or_node => $val); my $y; my $x = $self->[ROOT]; while($x) { $y = $x; # Handle case of inserting node with duplicate key. if($cmp ? $cmp->($z->[_KEY], $x->[_KEY]) == 0 : $z->[_KEY] eq $x->[_KEY]) { my $old_val = $x->[_VAL]; $x->[_VAL] = $z->[_VAL]; return $old_val; } if($cmp ? $cmp->($z->[_KEY], $x->[_KEY]) < 0 : $z->[_KEY] lt $x->[_KEY]) { $x = $x->[_LEFT]; } else { $x = $x->[_RIGHT]; } } # insert new node $z->[_PARENT] = $y; if(not defined $y) { $self->[ROOT] = $z; } else { if($cmp ? $cmp->($z->[_KEY], $y->[_KEY]) < 0 : $z->[_KEY] lt $y->[_KEY]) { $y->[_LEFT] = $z; } else { $y->[_RIGHT] = $z; } } $self->_fix_after_insertion($z); $self->[SIZE]++; return; } *STORE = \&put; sub _fix_after_insertion { my $self = shift; my $x = shift or croak('Missing arg: node'); $x->[_COLOR] = RED; while($x != $self->[ROOT] && $x->[_PARENT][_COLOR] == RED) { my ($child, $rotate1, $rotate2); if(($x->[_PARENT] || 0) == ($x->[_PARENT][_PARENT][_LEFT] || 0)) { ($child, $rotate1, $rotate2) = (_RIGHT, '_left_rotate', '_right_rotate'); } else { ($child, $rotate1, $rotate2) = (_LEFT, '_right_rotate', '_left_rotate'); } my $y = $x->[_PARENT][_PARENT][$child]; if($y && $y->[_COLOR] == RED) { $x->[_PARENT][_COLOR] = BLACK; $y->[_COLOR] = BLACK; $x->[_PARENT][_PARENT][_COLOR] = RED; $x = $x->[_PARENT][_PARENT]; } else { if($x == ($x->[_PARENT][$child] || 0)) { $x = $x->[_PARENT]; $self->$rotate1($x); } $x->[_PARENT][_COLOR] = BLACK; $x->[_PARENT][_PARENT][_COLOR] = RED; $self->$rotate2($x->[_PARENT][_PARENT]); } } $self->[ROOT][_COLOR] = BLACK; } sub delete { my ($self, $key_or_node) = @_; defined $key_or_node or croak("Can't use undefined value as key or node"); my $z = (ref $key_or_node eq 'Tree::RB::Node') ? $key_or_node : ($self->lookup($key_or_node))[1]; return unless $z; my $y; if($z->[_LEFT] && $z->[_RIGHT]) { # (Notes kindly provided by Christopher Gurnee) # When deleting a node 'z' which has two children from a binary search tree, the # typical algorithm is to delete the successor node 'y' instead (which is # guaranteed to have at most one child), and then to overwrite the key/values of # node 'z' (which is still in the tree) with the key/values (which we don't want # to lose) from the now-deleted successor node 'y'. # Since we need to return the deleted item, it's not good enough to overwrite the # key/values of node 'z' with those of node 'y'. Instead we swap them so we can # return the deleted values. $y = $z->successor; ($z->[_KEY], $y->[_KEY]) = ($y->[_KEY], $z->[_KEY]); ($z->[_VAL], $y->[_VAL]) = ($y->[_VAL], $z->[_VAL]); } else { $y = $z; } # splice out $y my $x = $y->[_LEFT] || $y->[_RIGHT]; if(defined $x) { $x->[_PARENT] = $y->[_PARENT]; if(! defined $y->[_PARENT]) { $self->[ROOT] = $x; } elsif($y == $y->[_PARENT][_LEFT]) { $y->[_PARENT][_LEFT] = $x; } else { $y->[_PARENT][_RIGHT] = $x; } # Null out links so they are OK to use by _fix_after_deletion delete @{$y}[_PARENT, _LEFT, _RIGHT]; # Fix replacement if($y->[_COLOR] == BLACK) { $self->_fix_after_deletion($x); } } elsif(! defined $y->[_PARENT]) { # return if we are the only node delete $self->[ROOT]; } else { # No children. Use self as phantom replacement and unlink if($y->[_COLOR] == BLACK) { $self->_fix_after_deletion($y); } if(defined $y->[_PARENT]) { no warnings 'uninitialized'; if($y == $y->[_PARENT][_LEFT]) { delete $y->[_PARENT][_LEFT]; } elsif($y == $y->[_PARENT][_RIGHT]) { delete $y->[_PARENT][_RIGHT]; } delete $y->[_PARENT]; } } $self->[SIZE]--; return $y; } *DELETE = \&delete; sub _fix_after_deletion { my $self = shift; my $x = shift or croak('Missing arg: node'); while($x != $self->[ROOT] && color_of($x) == BLACK) { my ($child1, $child2, $rotate1, $rotate2); no warnings 'uninitialized'; if($x == left_of(parent_of($x))) { ($child1, $child2, $rotate1, $rotate2) = (\&right_of, \&left_of, '_left_rotate', '_right_rotate'); } else { ($child1, $child2, $rotate1, $rotate2) = (\&left_of, \&right_of, '_right_rotate', '_left_rotate'); } use warnings; my $w = $child1->(parent_of($x)); if(color_of($w) == RED) { set_color($w, BLACK); set_color(parent_of($x), RED); $self->$rotate1(parent_of($x)); $w = right_of(parent_of($x)); } if(color_of($child2->($w)) == BLACK && color_of($child1->($w)) == BLACK) { set_color($w, RED); $x = parent_of($x); } else { if(color_of($child1->($w)) == BLACK) { set_color($child2->($w), BLACK); set_color($w, RED); $self->$rotate2($w); $w = $child1->(parent_of($x)); } set_color($w, color_of(parent_of($x))); set_color(parent_of($x), BLACK); set_color($child1->($w), BLACK); $self->$rotate1(parent_of($x)); $x = $self->[ROOT]; } } set_color($x, BLACK); } sub _left_rotate { my $self = shift; my $x = shift or croak('Missing arg: node'); my $y = $x->[_RIGHT] or return; $x->[_RIGHT] = $y->[_LEFT]; if($y->[_LEFT]) { $y->[_LEFT]->[_PARENT] = $x; } $y->[_PARENT] = $x->[_PARENT]; if(not defined $x->[_PARENT]) { $self->[ROOT] = $y; } else { $x == $x->[_PARENT]->[_LEFT] ? $x->[_PARENT]->[_LEFT] = $y : $x->[_PARENT]->[_RIGHT] = $y; } $y->[_LEFT] = $x; $x->[_PARENT] = $y; } sub _right_rotate { my $self = shift; my $y = shift or croak('Missing arg: node'); my $x = $y->[_LEFT] or return; $y->[_LEFT] = $x->[_RIGHT]; if($x->[_RIGHT]) { $x->[_RIGHT]->[_PARENT] = $y } $x->[_PARENT] = $y->[_PARENT]; if(not defined $y->[_PARENT]) { $self->[ROOT] = $x; } else { $y == $y->[_PARENT]->[_RIGHT] ? $y->[_PARENT]->[_RIGHT] = $x : $y->[_PARENT]->[_LEFT] = $x; } $x->[_RIGHT] = $y; $y->[_PARENT] = $x; } 1; # Magic true value required at end of module __END__ =head1 NAME Tree::RB - Perl implementation of the Red/Black tree, a type of balanced binary search tree. =head1 SYNOPSIS use Tree::RB; my $tree = Tree::RB->new; $tree->put('France' => 'Paris'); $tree->put('England' => 'London'); $tree->put('Hungary' => 'Budapest'); $tree->put('Ireland' => 'Dublin'); $tree->put('Egypt' => 'Cairo'); $tree->put('Germany' => 'Berlin'); $tree->put('Alaska' => 'Anchorage'); # D'oh! Alaska isn't a Country $tree->delete('Alaska'); print scalar $tree->get('Ireland'); # 'Dublin' print $tree->size; # 6 print $tree->min->key; # 'Egypt' print $tree->max->key; # 'Ireland' print $tree->nth(0)->key; # 'Egypt' print $tree->nth(-1)->key; # 'Ireland' # print items, ordered by key my $it = $tree->iter; while(my $node = $it->next) { printf "key = %s, value = %s\n", $node->key, $node->val; } # print items in reverse order $it = $tree->rev_iter; while(my $node = $it->next) { printf "key = %s, value = %s\n", $node->key, $node->val; } # Hash interface tie my %capital, 'Tree::RB'; # or do this to store items in descending order tie my %capital, 'Tree::RB', sub { $_[1] cmp $_[0] }; $capital{'France'} = 'Paris'; $capital{'England'} = 'London'; $capital{'Hungary'} = 'Budapest'; $capital{'Ireland'} = 'Dublin'; $capital{'Egypt'} = 'Cairo'; $capital{'Germany'} = 'Berlin'; # print items in order while(my ($key, $val) = each %capital) { printf "key = $key, value = $val\n"; } =head1 DESCRIPTION This is a Perl implementation of the Red/Black tree, a type of balanced binary search tree. A tied hash interface is also provided to allow ordered hashes to be used. See the Wikipedia article at L for further information about Red/Black trees. =head1 INTERFACE =head2 new([CODEREF]) Creates and returns a new tree. If a reference to a subroutine is passed to new(), the subroutine will be used to override the tree's default lexical ordering and provide a user a defined ordering. This subroutine should be just like a comparator subroutine used with L, except that it doesn't do the $a, $b trick. For example, to get a case insensitive ordering my $tree = Tree::RB->new(sub { lc $_[0] cmp lc $_[1]}); $tree->put('Wall' => 'Larry'); $tree->put('Smith' => 'Agent'); $tree->put('mouse' => 'micky'); $tree->put('duck' => 'donald'); my $it = $tree->iter; while(my $node = $it->next) { printf "key = %s, value = %s\n", $node->key, $node->val; } =head2 resort(CODEREF) Changes the ordering of nodes within the tree. The new ordering is specified by a comparator subroutine which must be passed to resort(). See L for further information about the comparator. =head2 size() Returns the number of nodes in the tree. =head2 root() Returns the root node of the tree. This will either be undef if no nodes have been added to the tree, or a L object. See the L manual page for details on the Node object. =head2 min() Returns the node with the minimal key. =head2 max() Returns the node with the maximal key. =head2 nth(INDEX) Returns the node at the given (zero based) index, or undef if there is no node at that index. Negative indexes can be used, with -1 indicating the last node, -2 the penultimate node and so on. =head2 lookup(KEY, [MODE]) When called in scalar context, lookup(KEY) returns the value associated with KEY. When called in list context, lookup(KEY) returns a list whose first element is the value associated with KEY, and whose second element is the node containing the key/value. An optional MODE parameter can be passed to lookup() to influence which key is returned. The values of MODE are constants that are exported on demand by Tree::RB use Tree::RB qw[LUEQUAL LUGTEQ LULTEQ LUGREAT LULESS LUNEXT LUPREV]; =over =item LUEQUAL This is the default mode. Returns the node exactly matching the key, or C if not found. =item LUGTEQ Returns the node exactly matching the specified key, if this is not found then the next node that is greater than the specified key is returned. =item LULTEQ Returns the node exactly matching the specified key, if this is not found then the next node that is less than the specified key is returned. =item LUGREAT Returns the node that is just greater than the specified key - not equal to. This mode is similar to LUNEXT except that the specified key need not exist in the tree. =item LULESS Returns the node that is just less than the specified key - not equal to. This mode is similar to LUPREV except that the specified key need not exist in the tree. =item LUNEXT Looks for the key specified, if not found returns C. If the node is found returns the next node that is greater than the one found (or C if there is no next node). This can be used to step through the tree in order. =item LUPREV Looks for the key specified, if not found returns C. If the node is found returns the previous node that is less than the one found (or C if there is no previous node). This can be used to step through the tree in reverse order. =back =head2 get(KEY) get() is an alias for lookup(). =head2 iter([KEY]) Returns an iterator object that can be used to traverse the tree in order. The iterator object supports a 'next' method that returns the next node in the tree or undef if all of the nodes have been visited. See the synopsis for an example. If a key is supplied, the iterator returned will traverse the tree in order starting from the node with key greater than or equal to the specified key. $it = $tree->iter('France'); my $node = $it->next; print $node->key; # -> 'France' =head2 rev_iter([KEY]) Returns an iterator object that can be used to traverse the tree in reverse order. If a key is supplied, the iterator returned will traverse the tree in order starting from the node with key less than or equal to the specified key. $it = $tree->rev_iter('France'); my $node = $it->next; print $node->key; # -> 'France' $it = $tree->rev_iter('Finland'); my $node = $it->next; print $node->key; # -> 'England' =head2 hseek(KEY, [{-reverse => 1|0}]) For tied hashes, determines the next entry to be returned by each. tie my %capital, 'Tree::RB'; $capital{'France'} = 'Paris'; $capital{'England'} = 'London'; $capital{'Hungary'} = 'Budapest'; $capital{'Ireland'} = 'Dublin'; $capital{'Egypt'} = 'Cairo'; $capital{'Germany'} = 'Berlin'; tied(%capital)->hseek('Germany'); ($key, $val) = each %capital; print "$key, $val"; # -> Germany, Berlin The direction of iteration can be reversed by passing a hashref with key '-reverse' and value 1 to hseek after or instead of KEY, e.g. to iterate over the hash in reverse order: tied(%capital)->hseek({-reverse => 1}); $key = each %capital; print $key; # -> Ireland The following calls are equivalent tied(%capital)->hseek('Germany', {-reverse => 1}); tied(%capital)->hseek({-key => 'Germany', -reverse => 1}); =head2 put(KEY, VALUE) Adds a new node to the tree. The first argument is the key of the node, the second is its value. If a node with that key already exists, its value is replaced with the given value and the old value is returned. Otherwise, undef is returned. =head2 delete(KEY) If the tree has a node with the specified key, that node is deleted from the tree and returned, otherwise C is returned. =head1 DEPENDENCIES L =head1 INCOMPATIBILITIES None reported. =head1 BUGS AND LIMITATIONS Please report any bugs or feature requests via the GitHub web interface at L. =head1 AUTHOR Arun Prasad C<< >> Some documentation has been borrowed from Benjamin Holzman's L and Damian Ivereigh's libredblack (L). =head1 ACKNOWLEDGEMENTS Thanks for bug reports go to Anton Petrusevich, Wes Thompson, Petre Mierlutiu, Tomer Vromen, Christopher Gurnee and Ole Bjorn Hessen. =head1 LICENCE AND COPYRIGHT Copyright (c) 2007, Arun Prasad C<< >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Node.pm100644001750001750 2063313166153713 15547 0ustar00arunarun000000000000Tree-RB-0.500006/lib/Tree/RBpackage Tree::RB::Node; use strict; use Carp; use Tree::RB::Node::_Constants; use vars qw( $VERSION @EXPORT_OK ); require Exporter; *import = \&Exporter::import; @EXPORT_OK = qw[set_color color_of parent_of left_of right_of]; $VERSION = '0.500006'; my %attribute = ( key => _KEY, val => _VAL, color => _COLOR, parent => _PARENT, left => _LEFT, right => _RIGHT, ); sub _accessor { my $index = shift; return sub { my $self = shift; if (@_) { $self->[$index] = shift; } return $self->[$index]; }; } while(my($at, $idx) = each %attribute) { no strict 'refs'; *$at = _accessor($idx); } sub new { my $class = shift; my $obj = []; if (@_) { $obj->[_KEY] = shift; $obj->[_VAL] = shift; } return bless $obj, $class; } sub min { my $self = shift; while ($self->[_LEFT]) { $self = $self->[_LEFT]; } return $self; } sub max { my $self = shift; while ($self->[_RIGHT]) { $self = $self->[_RIGHT]; } return $self; } sub leaf { my $self = shift; while (my $any_child = $self->[_LEFT] || $self->[_RIGHT]) { $self = $any_child; } return $self; } sub successor { my $self = shift; if ($self->[_RIGHT]) { return $self->[_RIGHT]->min; } my $parent = $self->[_PARENT]; while ($parent && $parent->[_RIGHT] && $self == $parent->[_RIGHT]) { $self = $parent; $parent = $parent->[_PARENT]; } return $parent; } sub predecessor { my $self = shift; if ($self->[_LEFT]) { return $self->[_LEFT]->max; } my $parent = $self->[_PARENT]; while ($parent && $parent->[_LEFT] && $self == $parent->[_LEFT]) { $self = $parent; $parent = $parent->[_PARENT]; } return $parent; } sub as_lol { my $self = shift; my $node = shift || $self; my $aref; push @$aref, $node->[_LEFT] ? $self->as_lol($node->[_LEFT]) : '*'; push @$aref, $node->[_RIGHT] ? $self->as_lol($node->[_RIGHT]) : '*'; my $color = ($node->[_COLOR] == RED ? 'R' : 'B'); no warnings 'uninitialized'; push @$aref, "$color:$node->[_KEY]"; return $aref; } sub strip { my $self = shift; my $callback = shift; my $x = $self; while($x) { my $leaf = $x->leaf; $x = $leaf->[_PARENT]; # detach $leaf from the (sub)tree no warnings "uninitialized"; if($leaf == $x->[_LEFT]) { undef $x->[_LEFT]; } else { undef $x->[_RIGHT]; } undef $leaf->[_PARENT]; if($callback) { $callback->($leaf); } if(!$x->[_LEFT] && !$x->[_RIGHT]) { $x = $x->[_PARENT]; } } } sub DESTROY { $_[0]->strip; } # Null aware accessors to assist with rebalancings during insertion and deletion # # A weird case of Java to the rescue! # These are inspired by http://www.javaresearch.org/source/jdk142/java/util/TreeMap.java.html # which was found via http://en.wikipedia.org/wiki/Red-black_tree#Implementations sub set_color { my ($node, $color) = @_; if($node) { $node->[_COLOR] = $color || BLACK; } } sub color_of { $_[0] ? $_[0]->[_COLOR] : BLACK; } sub parent_of { $_[0] ? $_[0]->[_PARENT] : undef; } sub left_of { $_[0] ? $_[0]->[_LEFT] : undef; } sub right_of { $_[0] ? $_[0]->[_RIGHT] : undef; } 1; # Magic true value required at end of module __END__ =head1 NAME Tree::RB::Node - A node class for implementing Red/Black trees =head1 VERSION This document describes Tree::RB::Node version 0.500006 =head1 SYNOPSIS use Tree::RB; my $tree = Tree::RB->new; $tree->put('France' => 'Paris'); $tree->put('England' => 'London'); my $node = $tree->delete('France'); # $node is a Tree::RB::Node object print $node->key; # 'France' print $node->val; # 'Paris' =head1 DESCRIPTION A Tree::RB tree is made up of nodes that are objects of type Tree::RB::Node =head1 INTERFACE A Tree::RB::Node object supports the following methods: =head2 new() Creates and returns a new node. =head2 key([KEY]) Get/set the key of the node. This is what the nodes are sorted by in the tree. =head2 val([VALUE]) Get/set the value of the node. This can be any scalar. =head2 color([COLOR]) Get/set the color of the node. Valid colors are the constants RED and BLACK which are exported by Tree::RB::Node::_Constants =head2 parent([PARENT]) Get/set the parent of the node, which must be another Tree::RB::Node object. =head2 left([NODE]) Get/set the left child node of the node, which must be another Tree::RB::Node object. =head2 right([NODE]) Get/set the right child node of the node, which must be another Tree::RB::Node object. =head2 min() Returns the node with the minimal key starting from this node. =head2 max() Returns the node with the maximal key starting from this node. =head2 leaf() Returns the first leaf node found starting from this node, using a depth first, left to right search. =head2 successor() Returns the node with the smallest key larger than this node's key, or C if it is the node with the maximal key. =head2 predecessor() Returns the node with the greatest key smaller than this node's key, or C if it is the node with the minimal key. =head2 as_lol([NODE]) Returns a list of lists representing the tree whose root is either NODE if NODE is specified, or this node otherwise. This could be used for printing a tree, as the following snippet shows (this assumes that Tree::DAG_Node is also installed) use strict; use Tree::DAG_Node; use Tree::RB; my $t = Tree::RB->new; foreach (qw/the rain in spain falls mainly in the plains/) { $t->put($_, "${_} val"); } my $tree = Tree::DAG_Node->lol_to_tree( $t->root->as_lol ); $, = "\n"; print @{ $tree->draw_ascii_tree }; This will print | /-------------------\ | | /-----------\ /------\ | | | | <*> /---\ /------\ /---\ | | | | | | <*> <*> <*> <*> <*> /---\ | | <*> <*> =head2 strip([$callback]) Strips off all nodes under this node. If a callback is specified, it will be called once for each node that is detached, with the detached node as its sole argument. =head1 DEPENDENCIES None. =head1 INCOMPATIBILITIES None reported. =head1 BUGS AND LIMITATIONS Please report any bugs or feature requests to C, or through the web interface at L. =head1 AUTHOR Arun Prasad C<< >> Some documentation has been borrowed from Benjamin Holzman's L =head1 LICENCE AND COPYRIGHT Copyright (c) 2007, Arun Prasad C<< >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. _Constants.pm100644001750001750 527313166153713 17645 0ustar00arunarun000000000000Tree-RB-0.500006/lib/Tree/RB/Nodepackage Tree::RB::Node::_Constants; use strict; use Carp; use vars qw( $VERSION @EXPORT ); $VERSION = '0.500006'; require Exporter; *import = \&Exporter::import; my @Node_slots; my @Node_colors; BEGIN { @Node_slots = qw(PARENT LEFT RIGHT COLOR KEY VAL); @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; # Magic true value required at end of module __END__ =head1 NAME Tree::RB::Node::_Constants - Tree::RB guts =head1 VERSION This document describes Tree::RB::Node::_Constants version 0.500006 =head1 SYNOPSIS (internal use only) =head1 DESCRIPTION This module exists solely to provide contants for use by Tree::RB and Tree::RB::Node. =head1 DEPENDENCIES L =head1 INCOMPATIBILITIES None reported. =head1 BUGS AND LIMITATIONS Please report any bugs or feature requests to C, or through the web interface at L. =head1 AUTHOR Arun Prasad C<< >> =head1 LICENCE AND COPYRIGHT Copyright (c) 2007, Arun Prasad C<< >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. minil.toml100644001750001750 14213166153713 14312 0ustar00arunarun000000000000Tree-RB-0.500006name = "Tree-RB" # badges = ["travis"] authority="cpan:ARUNBEAR" module_maker="ModuleBuildTiny" 00.load.t100644001750001750 20013166153713 14065 0ustar00arunarun000000000000Tree-RB-0.500006/tuse Test::More tests => 3; BEGIN { use_ok( 'Tree::RB' ); use_ok( 'Tree::RB::Node' ); use_ok( 'Tree::RB::Node::_Constants' ); } 01.node.t100644001750001750 443213166153713 14127 0ustar00arunarun000000000000Tree-RB-0.500006/tuse Test::More tests => 27; use strict; use warnings; use_ok( 'Tree::RB::Node' ); diag( "Testing Tree::RB::Node $Tree::RB::Node::VERSION" ); foreach my $m (qw[ new key val color parent left right min max successor predecessor ]) { can_ok('Tree::RB::Node', $m); } my $node = Tree::RB::Node->new('England' => 'London'); # [England: London] isa_ok( $node, 'Tree::RB::Node' ); is($node->key, 'England', 'key retrieved after new'); is($node->val, 'London', 'value retrieved after new'); $node->key('France'); # [France: London] is($node->key, 'France', 'key retrieved after set'); $node->val('Paris'); # [France: Paris] is($node->val, 'Paris', 'value retrieved after set'); $node->color(1); is($node->color, 1, 'color retrieved after set'); my $left_node = Tree::RB::Node->new('England' => 'London'); $left_node->parent($node); $node->left($left_node); # [France: Paris] # / # [England: London] is($node->left, $left_node, 'left retrieved after set'); my $right_node = Tree::RB::Node->new('Hungary' => 'Budapest'); $right_node->parent($node); $node->right($right_node); # [France: Paris] # / \ # [England: London] [Hungary: Budapest] is($node->right, $right_node, 'right retrieved after set'); my $parent_node = Tree::RB::Node->new('Ireland' => 'Dublin'); $parent_node->left($node); $node->parent($parent_node); # [Ireland: Dublin] # / # [France: Paris] # / \ # [England: London] [Hungary: Budapest] is($node->parent, $parent_node, 'parent retrieved after set'); is($parent_node->min->key, 'England', 'min'); is($node->max->key, 'Hungary', 'max'); is($right_node->successor->key, 'Ireland', 'successor'); is($parent_node->predecessor->key, 'Hungary', 'predecessor'); my $egypt = Tree::RB::Node->new('Egypt' => 'Cairo'); $egypt->parent($left_node); $left_node->right($egypt); # [Ireland: Dublin] # / # [France: Paris] # / \ # [England: London] [Hungary: Budapest] # \ # [Egypt: Cairo] is($parent_node->leaf->key, 'Egypt', 'leaf'); $parent_node->strip; is($parent_node->leaf->key, 'Ireland', 'strip'); 01.node_constants.t100644001750001750 46113166153713 16201 0ustar00arunarun000000000000Tree-RB-0.500006/tuse Test::More tests => 9; use_ok( 'Tree::RB::Node::_Constants' ); diag( "Testing Tree::RB::Node::_Constants $Tree::RB::Node::_Constants::VERSION" ); foreach my $m (qw[ _PARENT _LEFT _RIGHT _COLOR _KEY _VAL BLACK RED ]) { can_ok('Tree::RB::Node::_Constants', $m); }02.tree.t100644001750001750 630613166153713 14144 0ustar00arunarun000000000000Tree-RB-0.500006/tuse Test::More tests => 39; use strict; use warnings; use Data::Dumper; use_ok( 'Tree::RB' ); diag( "Testing Tree::RB $Tree::RB::VERSION" ); foreach my $m (qw[ new put iter rev_iter size ]) { can_ok('Tree::RB', $m); } my $tree = Tree::RB->new; isa_ok($tree, 'Tree::RB'); ok($tree->size == 0, 'New tree has size zero'); $tree->put('France' => 'Paris'); $tree->put('England' => 'London'); $tree->put('Hungary' => 'Budapest'); $tree->put('Ireland' => 'Dublin'); $tree->put('Egypt' => 'Cairo'); ok(! defined $tree->put('Germany' => 'Bonn'), 'put with non existing key'); is($tree->put('Germany' => 'Berlin'), 'Bonn', 'put with existing key'); ok($tree->size == 6, 'size check after inserts'); is($tree->min->key, 'Egypt', 'min'); is($tree->max->key, 'Ireland', 'max'); # Iterator tests my $it; $it = $tree->iter; isa_ok($it, 'Tree::RB::Iterator'); can_ok($it, 'next'); my @iter_tests = ( sub { my $node = $_[0]->next; ok($node->key eq 'Egypt' && $node->val eq 'Cairo', 'iterator check'); }, sub { my $node = $_[0]->next; ok($node->key eq 'England' && $node->val eq 'London', 'iterator check'); }, sub { my $node = $_[0]->next; ok($node->key eq 'France' && $node->val eq 'Paris', 'iterator check'); }, sub { my $node = $_[0]->next; ok($node->key eq 'Germany' && $node->val eq 'Berlin', 'iterator check'); }, sub { my $node = $_[0]->next; ok($node->key eq 'Hungary' && $node->val eq 'Budapest', 'iterator check'); }, sub { my $node = $_[0]->next; ok($node->key eq 'Ireland' && $node->val eq 'Dublin', 'iterator check'); }, sub { my $node = $_[0]->next; ok(!defined $node, 'iterator check - no more items'); }, ); foreach my $t (@iter_tests) { $t->($it); } # Reverse iterator tests $it = $tree->rev_iter; isa_ok($it, 'Tree::RB::Iterator'); can_ok($it, 'next'); my @rev_iter_tests = (reverse(@iter_tests[0 .. $#iter_tests-1]), $iter_tests[-1]); =pod Longer way to reverse my @rev_iter_tests = @iter_tests; @rev_iter_tests = (pop @rev_iter_tests, @rev_iter_tests); @rev_iter_tests = reverse @rev_iter_tests; =cut foreach my $t (@rev_iter_tests) { $t->($it); } # seeking my $node; $it = $tree->iter('France'); $node = $it->next; is($node->key, 'France', 'seek check, key exists'); $it = $tree->iter('Iceland'); $node = $it->next; is($node->key, 'Ireland', 'seek check, key does not exist but is lt max key'); $it = $tree->iter('Timbuktu'); $node = $it->next; ok(!defined $node, 'seek check, non existant key gt all keys') or diag(Dumper($node)); # seeking in reverse $it = $tree->rev_iter('Hungary'); $node = $it->next; is($node->key, 'Hungary', 'reverse seek check, key exists'); $node = $it->next; is($node->key, 'Germany', 'reverse seek check, next key lt this one'); $it = $tree->rev_iter('Finland'); $node = $it->next; is($node->key, 'England', 'reverse seek check, key does not exist but is gt min key'); $it = $tree->rev_iter('Albania'); $node = $it->next; ok(!defined $node, 'reverse seek check, non existant key lt all keys'); $tree->put('Timbuktu' => ''); is($tree->get('Timbuktu'), '', 'False values can be stored'); __END__ 03.delete.t100644001750001750 421013166153713 14440 0ustar00arunarun000000000000Tree-RB-0.500006/tuse Test::More tests => 13; use strict; use warnings; use Tree::RB; diag( "Testing deletion in Tree::RB $Tree::RB::VERSION" ); my $tree = Tree::RB->new; $tree->put('England' => 'London'); my $size = $tree->size; $tree->delete('England'); ok($size - $tree->size == 1, 'size goes down by one on removing a node'); my ($val, $node) = $tree->lookup('England'); ok(! defined $node, 'lookup deleted node'); ok(! defined $val, q[lookup deleted node's value]); $tree->put('France' => 'Paris'); $tree->put('England' => 'London'); $tree->put('Hungary' => 'Budapest'); $tree->put('Ireland' => 'Dublin'); $tree->put('Egypt' => 'Cairo'); # | # # /--------------\ # | | # # /------\ /-------\ # | | | | # <*> <*> # /---\ /---\ # | | | | # <*> <*> <*> <*> is($tree->delete('Hungary')->key, 'Hungary', 'delete intermediate node'); $tree->put('Hungary' => 'Budapest'); is($tree->delete('England')->key, 'England', 'delete intermediate node'); $tree->put('England' => 'London'); $tree->delete('Egypt'); is($tree->min->key, 'England', q[new min after deleting current min]); is($tree->max->key, 'Ireland', q[max not changed after deleting current min]); # | # # /-------------\ # | | # # /---\ /-------\ # | | | | # <*> <*> <*> # /---\ # | | # <*> <*> $tree->delete('Ireland'); is($tree->max->key, 'Hungary', q[new max after deleting current max]); is($tree->min->key, 'England', q[min not changed after deleting current max]); # | # # /-----------\ # | | # # /---\ /---\ # | | | | # <*> <*> <*> <*> is($tree->delete('France')->key, 'France', 'delete node with two kids'); is($tree->root->key, 'Hungary', q[new root]); is($tree->max->key, 'Hungary', q[max not changed]); is($tree->min->key, 'England', q[min not changed]); 04.lookup.t100644001750001750 403513166153713 14515 0ustar00arunarun000000000000Tree-RB-0.500006/tuse Test::More tests => 18; use strict; use warnings; use Data::Dumper; use Tree::RB qw[LUEQUAL LUGTEQ LULTEQ LUGREAT LULESS LUNEXT LUPREV]; diag( "Testing lookup in Tree::RB $Tree::RB::VERSION" ); my $tree = Tree::RB->new; $tree->put('France' => 'Paris'); $tree->put('England' => 'London'); $tree->put('Hungary' => 'Budapest'); $tree->put('Ireland' => 'Dublin'); $tree->put('Egypt' => 'Cairo'); $tree->put('Germany' => 'Berlin'); # | # # /------------------\ # | | # # /------\ /-----------\ # | | | | # <*> # /---\ /---\ /---\ # | | | | | | # <*> <*> <*> <*> <*> <*> my $val; my $node; $val = $tree->lookup('Germany'); is($val, 'Berlin', 'lookup'); $val = $tree->lookup('Belgium', LUGTEQ); is($val, 'Cairo', 'lookup LUGTEQ: left'); $val = $tree->lookup('Finland', LUGTEQ); is($val, 'Paris', 'lookup LUGTEQ: right'); ($val, $node) = $tree->lookup('Russia', LUGTEQ); is_deeply($node, undef, 'lookup LUGTEQ: no gt node') or diag('got: '. Dumper($node)); is('Budapest', $tree->lookup('Hungary', LULTEQ), 'lookup LULTEQ: node exists'); ($val, $node) = $tree->lookup('Belgium', LULTEQ); is_deeply($node, undef, 'lookup LULTEQ: no lt node') or diag('got: '. Dumper($node)); is($tree->lookup('Jamaica', LULTEQ), 'Dublin', 'lookup LULTEQ: right'); is($tree->lookup('Iceland', LULTEQ), 'Budapest', 'lookup LULTEQ: left'); is($tree->lookup('Belgium', LUGREAT), 'Cairo', 'lookup LUGREAT: left'); is($tree->lookup('Finland', LUGREAT), 'Paris', 'lookup LUGREAT: right'); is $tree->nth(0)->key => 'Egypt', 'nth: 0'; is $tree->nth(1)->key => 'England', 'nth: 1'; is $tree->nth(4)->key => 'Hungary', 'nth: 4'; is $tree->nth(5)->key => 'Ireland', 'nth: 5'; is $tree->nth(-6)->key => 'Egypt', 'nth: -6'; is $tree->nth(-5)->key => 'England', 'nth: -5'; is $tree->nth(-2)->key => 'Hungary', 'nth: -2'; is $tree->nth(-1)->key => 'Ireland', 'nth: -1'; 06.tie.t100644001750001750 737313166153713 13777 0ustar00arunarun000000000000Tree-RB-0.500006/tuse Test::More tests => 37; use strict; use warnings; use Data::Dumper; use Tree::RB; diag( "Testing tied hash interface in Tree::RB $Tree::RB::VERSION" ); my %capital; my $tied = tie(%capital, 'Tree::RB'); isa_ok($tied, 'Tree::RB'); ok(keys %capital == 0, 'Empty hash - no keys'); ok(! exists $capital{'France'}, 'exists on empty hash'); $capital{'France'} = 'Paris'; ok(exists $capital{'France'}, 'exists after insert'); is($capital{'France'}, 'Paris', 'STORE and FETCH work'); my $deleted = delete $capital{'France'}; ok(keys %capital == 0, 'Size check after deleting sole element'); isa_ok($deleted, 'Tree::RB::Node'); ok($deleted->key eq 'France' && $deleted->val eq 'Paris', 'check deleted node'); setup(); ok(keys %capital == 6, 'Size check (keys) after inserts'); SKIP: { skip "tied hash SCALAR method not available in version $]", 1 if $] < 5.008_003; ok(scalar %capital == 6, 'Size check (scalar) after inserts'); } my @keys = qw/Egypt England France Germany Hungary Ireland/; is_deeply([keys %capital], \@keys, 'check keys list'); is_deeply([values %capital], [qw/Cairo London Paris Berlin Budapest Dublin/], 'check values list'); my ($key, $val); ($key, $val) = each %capital; ok($key eq 'Egypt' && $val eq 'Cairo', 'each check'); ($key, $val) = each %capital; ok($key eq 'England' && $val eq 'London', 'each check'); ($key, $val) = each %capital; ok($key eq 'France' && $val eq 'Paris', 'each check'); ($key, $val) = each %capital; ok($key eq 'Germany' && $val eq 'Berlin', 'each check'); ($key, $val) = each %capital; ok($key eq 'Hungary' && $val eq 'Budapest', 'each check'); ($key, $val) = each %capital; ok($key eq 'Ireland' && $val eq 'Dublin', 'each check'); ($key, $val) = each %capital; ok(!defined $key && !defined $val , 'each check - no more keys'); undef %capital; ok(keys %capital == 0, 'no keys after clearing hash'); ok(scalar %capital == 0, 'size zero after clearing hash'); untie %capital; ok(@$tied == 0, 'underlying array is empty after untie'); # Custom sorting $tied = tie(%capital, 'Tree::RB', sub { $_[1] cmp $_[0] }); isa_ok($tied, 'Tree::RB'); setup(); is_deeply([keys %capital], [reverse @keys], 'check keys list (reverse sort)'); untie %capital; # Seeking $tied = tie(%capital, 'Tree::RB'); setup(); can_ok('Tree::RB', 'hseek'); $tied->hseek('Egypt'); $key = each %capital; is($key, 'Egypt', 'hseek to min key'); $tied->hseek('Germany'); ($key, $val) = each %capital; is($key, 'Germany', 'hseek check key'); $key = each %capital; is($key, 'Hungary', 'hseek check sequence'); $tied->hseek('Japan'); ($key, $val) = each %capital; is_deeply([$key, $val], [undef, undef], 'hseek to key gt max key'); $tied->hseek('Iceland'); $key = each %capital; is($key, 'Ireland', 'hseek to non existent key lt max key'); $tied->hseek({-key=> 'Belgium'}); $key = each %capital; is($key, 'Egypt', 'hseek to key lt min key'); # Reverse Seeking $tied->hseek({-reverse=> 1}); $key = each %capital; is($key, 'Ireland', 'reverse hseek to max key'); $key = each %capital; is($key, 'Hungary', 'reverse hseek check sequence'); $tied->hseek('Germany', {-reverse=> 1}); $key = each %capital; is($key, 'Germany', 'reverse hseek to existing key'); $tied->hseek('Iceland', {-reverse=> 1}); $key = each %capital; is($key, 'Hungary', 'reverse hseek to non existing key gt min'); $tied->hseek('Belgium', {-reverse=> 1}); $key = each %capital; is_deeply($key, undef, 'reverse hseek to non existing key lt min'); $tied->hseek({-reverse=> 1, -key=> 'Panama'}); $key = each %capital; is($key, 'Ireland', 'reverse hseek to non existing key gt max'); ## Helper Functions sub setup { %capital = ( France => 'Paris', England => 'London', Hungary => 'Budapest', Ireland => 'Dublin', Egypt => 'Cairo', Germany => 'Berlin', ); } 07.rt_47894.t100644001750001750 43213166153713 14370 0ustar00arunarun000000000000Tree-RB-0.500006/tuse Test::More tests => 2; use strict; use warnings; use Tree::RB; my $tree = Tree::RB->new(); my $iter = $tree->iter(); my $iter_with_key = $tree->iter('somekey'); ok(!defined $iter->next, 'iterate empty tree'); ok(!defined $iter_with_key->next, 'iterate empty tree with key'); META.yml100644001750001750 222013166153713 13575 0ustar00arunarun000000000000Tree-RB-0.500006--- abstract: 'Perl implementation of the Red/Black tree, a type of balanced binary search tree. ' author: - 'Arun Prasad C<< >>' build_requires: ExtUtils::MakeMaker: '6.36' Test::More: '0.42' configure_requires: Module::Build::Tiny: '0.035' dynamic_config: 0 generated_by: 'Minilla/v3.0.13, CPAN::Meta::Converter version 2.150005' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Tree-RB no_index: directory: - t - xt - inc - share - eg - examples - author - builder provides: Tree::RB: file: lib/Tree/RB.pm version: '0.500006' Tree::RB::Node: file: lib/Tree/RB/Node.pm version: '0.500006' requires: enum: '0' resources: bugtracker: https://github.com/arunbear/Tree-RB/issues homepage: https://github.com/arunbear/Tree-RB repository: git://github.com/arunbear/Tree-RB.git version: '0.500006' x_authority: cpan:ARUNBEAR x_contributors: - 'Arun Prasaad ' - 'Arun Prasaad ' - 'Arun Prasaad ' x_serialization_backend: 'CPAN::Meta::YAML version 0.016' MANIFEST100644001750001750 41613166153713 13442 0ustar00arunarun000000000000Tree-RB-0.500006Build.PL Changes LICENSE META.json Makefile README.md cpanfile lib/Tree/RB.pm lib/Tree/RB/Node.pm lib/Tree/RB/Node/_Constants.pm minil.toml t/00.load.t t/01.node.t t/01.node_constants.t t/02.tree.t t/03.delete.t t/04.lookup.t t/06.tie.t t/07.rt_47894.t META.yml MANIFEST