主張
ã¿ã¤ãã«éããScalaã® ArrayBuffer
ã§ã¯ init
ã ãã§ãªã dropRightInPlace
ã使ããã¨ãæ¤è¨ãã¦ã¿ã¾ãããï¼å
ã® ArrayBuffer
ã®ãã¼ã¿ã使ããªãã¨ããæ¡ä»¶ã¯ä»ãã¾ãã dropRightInPlace
ã®æ¹ãé«éã§ãã
val filled = ArrayBuffer.fill(1000000)(1) assert(filled.init.length == 999999)
val filled = ArrayBuffer.fill(1000000)(1) assert(filled.dropRightInPlace(1).length == 999999)
è足
Scalaã触ã£ã¦ããã¨ãList
ã§ã¯ ::
ãä»ã®ã³ã¬ã¯ã·ã§ã³ã§ã +:
, :+
ã使ããã¨ãå¤ãã§ãããã®å½±é¿ããã£ã¦ head
ã«å¯¾ã㦠tail
, init
ã«å¯¾ã㦠last
ãæèãããã¨ãå¤ãã¨æãã¾ãã
ãããªããªã§ foldLeft
ä¸ã§ ArrayBuffer
ãã init
ã使ã£ã¦ããããåããã¦ã¿ãã¨ãã«ãªããé
ãã¦é ãæ±ãã¦ãã¾ãã¾ããã
ä¸æè°ã«æã£ã¦ããã¨ãã init
ãcopyãä½æãã¦ãããã¨ã«æ°ãä»ãã¾ãããæ°ä»ãã¦ãã¾ãã°å½ç¶ã§ãããã
Rustè¨èªã® Vec
ã® pop
ã®ããã«æå¾ã®è¦ç´ ãmutableã«åé¤ããã°copyãä½æããã«é«éã«åä½ããã¯ããªã®ã§ãããpop
ãªãã¦methodã¯è¦å½ããã¾ããã§ããã
é ãæ»ã£ã¦ããã¨ãããããã£ã½ãmethodã« trimEnd
ãããã¾ãããæã¡è¾¼ãã§ã¿ã㨠"use dropRightInPlace instead"
ã¨æããã¾ããã dropRightInPlace
ã®å®è£
ãè¦ã¦ã¿ãã¨ãããã¤ã ãï¼ã¨ãªã£ãã®ã§ä½¿ç¨ãã¦ã¿ãã¨ãããæå¾
éãã®é度ãåºã¾ãããå¬ããã
èªåã¨ãã¦ã¯ pop
ã¿ãããªãè¦ç´ ã ä¸ã¤ã ã åé¤ããé«éãªmethodããmutable㪠ArrrayBuffer
ã«ã¯ããã°ãã£ã¨ãµã¯ãã¨æ¸ããã®ã«ã¨æãã°ããã§ããâ¦â¦å®ã¯ãã£ãããããã§ãããï¼