[[
find
]]
Xtal Unofficial Wiki
現在位置:
Xtal Unofficial Wiki
»
Xtal Reference
»
Iterator
»
find
文書の表示
以前のリビジョン
最近の変更
サイトマップ
ログイン
この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。
====== find ====== ===== Description ===== //pred//がtrueを返す要素を見つけるまでイテレートし、見つけたらその要素を返し、見つからなければundefinedを返します。 ===== Example ===== ランキングっぽい処理をするサンプルです。 ==== C++ ==== ==== Xtal ==== <code cpp> ranking : [ [1000, "foo", "15:23:33"], [800, "bar", "15:25:08"], [750, "piyo", "08:22:45"], [0, "", "--:--:--"], [0, "", "--:--:--"] ]; ranking.p; newScore : 790; newName : "hoge"; newTime : "15:46:10"; i, it : ranking.with_index.find(|i, x| x[0]<newScore); if (i){ ranking.insert(i, [newScore, newName, newTime]); ranking.resize(5); %f[rank in!(rank %d)](i+1).p; } ranking.p; </code> ==== Output ==== <code> [[1000, foo, 15:23:33], [800, bar, 15:25:08], [750, piyo, 08:22:45], [0, , --:--:--], [0, , --:--:--]] rank in!(rank 3) [[1000, foo, 15:23:33], [800, bar, 15:25:08], [790, hoge, 15:46:10], [750, piyo, 08:22:45], [0, , --:--:--]] </code>
reference/iterator/find.txt · 最終更新: 2011/07/15 16:45 by sukai
文書の表示
以前のリビジョン
文書の先頭へ