ToDo:
http://mput.dip.jp/mput/?date=20060207#c04
¤Îµ½Ò¤ò¸«¤Æ¡£ ÇÛÎó¤Î¥±¥Ä»ý¤Ã¤Æ¤¯¤ë¤Î¤Ë¤Ê¤ó¤Ç O(1)¤¬¤Ç¤¤ë¤ó¤À¤í¤¦¤È»×¤Ã¤Æ¡£ ¤Æ¤¤¤¦¤« Array ¤ÏÇÛÎó¤À¤È»×¤Ã¤Æ¤¿¤±¤ÉËÜÅö¤ËÇÛÎó¤Ê¤Î¤«¤È»×¤Ã¤Æ¡£
¤È¤ê¤¢¤¨¤º rb_ary_fetch ¤ò¸«¤¿¡£
return RARRAY(ary)->ptr[idx];
¤¦¤àÇÛÎó¡£
°ì±þ¼Â¸³¡£
i@u ~/test/ruby> ruby -e 'a=[1,2,3]; b=a[1..-1]; p a; p b; b[0]=4; p a; p b' [1, 2, 3] [2, 3] [1, 2, 3] [4, 3]
¤¦¤à¡£
¤È¤Ê¤ë¤È slice ¤¬ CoW ¤À¤È¤«¤«¤Ê¡Ä¤È»×¤Ã¤Æ rb_ary_subseq ¤È rb_ary_modify ¸«¤¿¤é CoW ¤Ý¤«¤Ã¤¿¡£ ¤¨¤é¤¤¡£¤Ç¤â¤½¤é¤½¤¦¤«¡£
(17:46)
(18:26)
Á° | 2006ǯ 4·î |
¼¡ | ||||
Æü | ·î | ²Ð | ¿å | ÌÚ | ¶â | ÅÚ |
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 |
Á´¤Æ¥ê¥ó¥¯¥Õ¥ê¡¼¤Ç¤¹¡£ ¥³¡¼¥ÉÊҤϼ«Í³¤Ë»ÈÍѤ·¤Æ¤¤¤¿¤À¤¤¤Æ¹½¤¤¤Þ¤»¤ó¡£ ¤½¤Î¾¤Î¤â¤Î¤ÏGPL°·¤¤¤Ç¤¢¤ì¤Ð¤¢¤é¤æ¤ë»ÈÍѤ˴ؤ·¤Æʸ¶ç¤Ï¸À¤¤¤Þ¤»¤ó¡£ ¤Ê¤Ë¤«¤¢¤ì¤Ð²¼µ¥á¡¼¥ë¥¢¥É¥ì¥¹¤Ø¡£
AHA!
http://www.google.com/
IHI-
UHUHU