ruby-****@sourc*****
ruby-****@sourc*****
2012年 8月 22日 (水) 11:16:23 JST
------------------------- REMOTE_ADDR = 70.49.49.99 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-trees ------------------------- @@ -172,7 +172,8 @@ list[7] = GroceryItem.new(P_CHILD, false, 3, "Chips") list[8] = GroceryItem.new(P_CHILD, true, 4, "Soda") -Parent/child relationship dictates that we bundle together all children of a parent below it. When later on application inserts new rows, particularly children, they have to be inserted into, or better immediately after, the list children of such a group. This makes indices to certain rows ephemeral. For instance if you store (memorize) an index to a certain row that index will became invalid after an insertion or a deletion of a row positioned before the element (row) for which you have stored (memorized) the index. Also the orderly sequential organization of the rows in a tree store allows you to readily process the data, since you can always be sure about locations of rows and the groupings of the children can be determined in a predictable manner. In our example program we exploited this fact in the loop calculating the totals for the parents by iterating through their groups of children: +Parent/child relationship dictates that we bundle together all children of a parent below it. When later on application inserts new rows, particularly children, they have to be inserted into, or better immediately after, the list children of such a group. This makes indices to certain rows ephemeral. For instance if you store (memorize) an index to a certain row that index will became invalid after an insertion or a deletion of a row positioned before the element (row) for which you have stored (memorized) the index. Before you start randomly insert new rows into the store, you just created, the orderly sequential organization of the rows in a tree store allows you to readily process the data, since you can be sure about locations of rows and the groupings of the children can be determined in a predictable manner. In our example program we exploited this fact in the loop calculating the totals for the parents by iterating through their groups of children: + list.each_with_index do |e, i|