因为专业所以放心

学习是没有起点和终点的......

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  15 Posts :: 0 Stories :: 1 Comments :: 0 Trackbacks

Map
------------------
map iim = new map(types::integer, types::class);
mapIterator it;
// Add some elements into the list...
iim.insert(1, new query());
iim.insert(2, new query());
iim.insert(4, new query());
// Create a list iterator
it = new mapIterator (iim);
print it.definitionString(); // prints “[int -> class] iterator”
print it.toString(); // prints “(begin)[(1 -> Query: query object 38824e0)]”
// Go on for as long as elements are found in the set...
while (it.more())
{
// fetch the next element
print it.key(); // prints 4 2 1
print it.value().toString(); // print something like Query object 3881270
it.next();
}
print it.toString();    // prints (end)
pause;
-----------------------------------
Set
------------------
set s1 = new set (types::integer);
int theElement;
setIterator it;
// Add some elements...
s1.add(3);
s1.add(4);
s1.add(13);
s1.add(1);
// Start a traversal of the elements in the set.
it = new setIterator(s1);
// The elements    are fetched in the order: 1, 3, 4, 13
print it.toString(); //    prints “(begin)[1]”
while (it.more())
{
//  Fetch the next element
theElement = it.value();
print theElement;
it.next();
}
pause;
-----------------------------------
List
----------------------
list il = new list(types::integer);
listIterator it;
// Add some elements into the list...
il.addStart(1);
il.addStart(2);
il.addStart(4);

// Create a list iterator
it = new listIterator (il);
   print it.definitionString(); // prints “int list iterator”
   print it.toString(); // prints “(begin)[4]”
// Go on for as long as elements are found in the list...
while (it.more())
   {
// fetch the next element
print it.value(); // prints 4 2 1
it.next();
   }
print it.toString();    // prints (end)
pause;

posted on 2006-08-12 11:21 舞熙 阅读(267) 评论(0)  编辑  收藏 所属分类: 程序设计语言

只有注册用户登录后才能发表评论。


网站导航: