{"image_url":null,"blog_url":"https://druby.hatenablog.com/","url":"https://druby.hatenablog.com/entry/20090515/1242384273","author_name":"m_seki","version":"1.0","title":"\u591a\u91cd\u4ee3\u5165\u306e\u30b5\u30f3\u30d7\u30eb","categories":[],"description":"\u5148\u65e5\u306etoRuby\u3067\u591a\u91cd\u4ee3\u5165\u304c\u8a71\u984c\u306b\u306a\u3063\u305f\u306e\u3067\u3001\u4f55\u304b\u30b5\u30f3\u30d7\u30eb\u3092! \u3068\u601d\u3063\u3066\u30d2\u30fc\u30d7\u30bd\u30fc\u30c8\u3092\u66f8\u3044\u3066\u307f\u305f\u3002\u591a\u91cd\u4ee3\u5165\u3092\u3064\u304b\u3063\u305fswap\u304c\u3042\u308a\u307e\u3059\u3002 pop\u3068push\u304c\u5bfe\u79f0\u306b\u306a\u3063\u3066\u306a\u304b\u3063\u305f\u306e\u3067\u4fee\u6b63\u3002(github) class Heap def initialize @ary = [] end def pop return @ary[0] ensure @ary[0] = @ary[-1] @ary.pop down(0) end def push(obj) @ary.push(obj) ensure up(@ary.size-1) end private def up(n) parent = (n -\u2026","published":"2009-05-15 19:44:33","author_url":"https://blog.hatena.ne.jp/m_seki/","type":"rich","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fdruby.hatenablog.com%2Fentry%2F20090515%2F1242384273\" title=\"\u591a\u91cd\u4ee3\u5165\u306e\u30b5\u30f3\u30d7\u30eb - @m_seki \u306e\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","provider_name":"Hatena Blog","provider_url":"https://hatena.blog","width":"100%","blog_title":"@m_seki \u306e","height":"190"}