using UnityEngine;
using System.Collections;
public class Chap10_7 : MonoBehaviour {
void ShowList(IEnumerable list){
//string s = "array =";
string s = list.GetType().Name + " : ";
foreach(object obj in list){
s += " " + obj.GetType().Name + "[" + obj.ToString() + "]";
GameObject go1 = obj as GameObject;
if(go1 != null){
}
}
print(s);
}
// Use this for initialization
void Start () {
/*
ArrayList array = new ArrayList();
array.Add(10);
array.Add(20.1f);
array.Add(30);
array.Add("Hello");
ShowList(array);
array.RemoveAt(2);
ShowList(array);
array.Remove(10);
ShowList(array);
Queue queue = new Queue();
queue.Enqueue(10);
queue.Enqueue("20");
queue.Enqueue("Hello");
ShowList(queue);
object a = queue.Dequeue();
object b = queue.Peek(); //important
print ("peek b = " + b);
ShowList(queue);
while(queue.Count > 0)
print ("deque =" + queue.Dequeue());
Stack stack = new Stack();
stack.Push(10);
stack.Push("20");
stack.Push("Hello");
ShowList(stack);
print ("Pop = " + stack.Pop());
ShowList(stack);
print ("Peek = " + stack.Peek());
ShowList(stack);
GameObject obj;
Hashtable ht = new Hashtable();
ht.Add("book", "C# Programming");
ht.Add("cook", "Kim Bab");
ht.Add ("twee", "Bird sing!");
ht["hobbang"] = "gwang ho ! singing";
ht[4] = "gwang ho2 ! singing";
print (ht["book"]);
print (ht["cook"]);
print (ht["twe"]); //not key -> null output
print (ht["hobbang"]);
print(ht[4]);
for(int i = 1; i < 4; i++){
print("key =" + i + "value =" + ht[i]); //array
}
*/
SortedList slist = new SortedList();
slist.Add(1,20);
slist.Add(3,30);
slist.Add(5,50);
slist.Add(2, 60);
ShowList(slist);
string s = "sorted list";
foreach(DictionaryEntry a in slist){
s += a.Value + ",";
}
print (s);
}
// Update is called once per frame
void Update () {
}
}
'Computer Language > 유니티' 카테고리의 다른 글
stack의 활용예 gameobject와 연결해서 사용이 가능하다 (0) | 2014.05.19 |
---|---|
이것만은 알고 갚시다. 10장 배열 컬렉션, 그리고 인덱서 (0) | 2014.05.19 |
바둑게임 선생님 일차! (0) | 2014.05.19 |
바둑돌 (0) | 2014.05.16 |
가변 배열 (0) | 2014.05.16 |