| ³ª¹« :: bptree. TREE :: BPTREE´Â B + Æ®¸®ÀÇ PERL ±¸ÇöÀÔ´Ï´Ù. |
Áö±Ý ´Ù¿î·Îµå |
³ª¹« :: bptree. ¼øÀ§ ¹× ¿ä¾à
- ƯÇã:
- Perl Artistic License
- °Ô½ÃÀÚ À̸§:
- Andrew Sterling Hanenkamp
- °Ô½ÃÀÚ À¥»çÀÌÆ®:
- http://search.cpan.org/~hanenkamp/
³ª¹« :: bptree. ű×
³ª¹« :: bptree. ¼³¸í
Tree :: BPTree´Â B + TreeÀÇ Perl ±¸ÇöÀÔ´Ï´Ù. TREE :: BPTREE´Â B + TRASÀÇ Perl ±¸ÇöÀÔ´Ï´Ù .Synopsis Tree :: BPTree; #ÀÌ Àμö´Â ½ÇÁ¦·Î ±âº»°ªÀÌ ±âº»°ªÀÔ´Ï´Ù. ³» $ tree = »õ Æ®¸® :: bptree (-n => 3, -unique => 0, -keycmp => sub {$ _ cmp $ _ }, -valuecmp => sub {$ _ $ _ },); #ÀÌ ¹®ÀÚ¿ÀÇ Ç׸ñÀ» À妽ÌÇÕ´Ï´Ù. MY $ string = "±× ÀÌ»óÀÇ ¹æ¹ýÀÌ ÀÖ½À´Ï´Ù"; # TMTOWTDI My $ i = 0; $ tree-> insert ($ _, $ i ++) foreach (split //, $ string); # ù ¹ø° 'T'³» $ T = $ TREA-> ã±â ( 'T')ÀÇ À妽º¸¦ ã½À´Ï´Ù. # ¸ðµç 'T'ÀÇ À妽º¸¦ ãÀ¸½Ê½Ã¿À. ³» @t = $ tree-> ã±â ( 't'); # ¿ì¸®´Â 'way'¶ó´Â ´Ü¾î¸¦ ÁÁ¾ÆÇÏÁö ¾ÊÀ¸¹Ç·Î, ³» $ i = index $ string, 'w'¸¦ Á¦°ÅÇØ º¾½Ã´Ù; $ tree-> »èÁ¦ ($ _, $ i ++) foreach (split //, substr ($ i, 4)); # Á¤·Ä ¼ø¼ $ tree-> ¿ª¹æÇâ; # °¢ ¿¬»êÀÚ°¡ ³»Àå µÈ °Í°ú ¸¶Âù°¡Áö·Î °¢ Å° / °ª ½ÖÀ» ¹Ýº¹ÇÕ´Ï´Ù (MY ($ Å°, $ value) = $ tree-> $ Å° => $ Valuen "; } # "°¢ ·çÇÁ"Ãʱâ $ TREA-> Àç¼³Á¤¿¡¼ Á¾·á ÇÒ ¶§ ¹Ýº¹ÀÚ¸¦ Àç¼³Á¤ÇϽʽÿÀ. # ÇÑ ¹ø¿¡ ¿©·¯ °³ÀÇ °¢ ·çÇÁ¸¦ »ç¿ëÇÏ´Â °Í¿¡µµ °ü½ÉÀÌÀÖÀ» ¼öµµ ÀÖ½À´Ï´Ù. Cursor ±¸¹®À» ÅëÇØ # °¡´ÉÇÕ´Ï´Ù. ¹Ýº¹ Áß¿¡ ¸ñ·Ï¿¡¼ °³º° ½Ö #À» »èÁ¦ÇÒ ¼öµµ ÀÖ½À´Ï´Ù. ³» $ cursor = $ tree-> new_cursor; while (my ($ Å°, $ value) = $ cursor-> °¢) {my $ nested = $ tree-> new_cursor; while (my ($ nkey, $ nvalue) = $ nested-> °¢) {($ Å° -> sheeknt_be_in_this_tree_with ($ nkey)) {$ nested-> »èÁ¦; }}} # iterator ¼ºê ·çƾ $ tree-> ¹Ýº¹ (ÇÏÀ§ {Àμâ "$ _ => $ _ n"}) »ç¿ëÀ» ¹Ýº¹ÇÕ´Ï´Ù. # ¹Ýº¹ÀÚ Àμâ Á¶ÀÎ ( ',', $ TREA-> ¸Ê (ÇÏÀ§ { "$ _ => $ _ "})¿¡ ÀÇÇØ ¹Ýȯ µÈ ¹Ýȯ °ª ¸ñ·ÏÀ» ¹ÝȯÇÏ´Â ¹Ýº¹ÀÚ ¼ºê ·çƾÀ» ¹ÝȯÇÕ´Ï´Ù. ,"N"; # grep-like ÀÛ¾÷ ³» @pairs = $ tree-> grep (sub {$ _ = ~ / s /}); @Keys = $ tree-> grep_keys (sub {$ _ = ~ / s /}); @values = $ tree-> grep_values (sub {$ _ = ~ / s /}); # ¸ðµç Å° °¡Á® ¿À±â, °ª ³» @all_keys = $ tree-> Å°; my @all_values = $ tree-> °ª; # ²¨³»¼ $ tree-> Áö¿ì±â¸¦ ½ÃÀÛÇϽʽÿÀ. b + ³ª¹«´Â ±ÕÇü ÀâÈù Æ®¸®ÀÔ´Ï´Ù. ±×µéÀº ¸¹Àº µ¥ÀÌÅ͸¦ À妽ÌÇÏ´Â µ¥ À¯¿ëÇÕ´Ï´Ù. ±×µéÀº 2-3-4 ³ª¹«¿Í »¡°£»ö ³ª¹«¿Í À¯»çÇÕ´Ï´Ù. ÀÌ ±¸ÇöÀº ÀÓÀÇÀÇ n value.requirements¸¦ »ç¿ëÇÏ¿© B + Æ®¸®¸¦ Áö¿øÇÕ´Ï´Ù. ¡¤ Perl ¿ä±¸ »çÇ× : ¡¤ Perl.
³ª¹« :: bptree. °ü·Ã ¼ÒÇÁÆ®¿þ¾î