Beispiel #1
0
        // Start is called before the first frame update
        void Start()
        {
            // 제네틱 사용하지 않았을때 스택을 사용하는 코드

            int          size   = 5;
            CStack <int> istack = new CStack <int>(size);


            for (int i = 0; i < 7; i++)
            {
                if (!istack.IsFull())
                {
                    istack.Push(i);
                }
                else
                {
                    Debug.Log("스택이 꽉 찼습니다. [저장 실패 : " + i + "]");
                }
            }

            while (!istack.IsEmpty())
            {
                Debug.Log(istack.Pop());
            }



            CStack <float> fstack = new CStack <float>(size);

            for (int i = 0; i < 7; i++)
            {
                if (!fstack.IsFull())
                {
                    fstack.Push(i * 1.2f);
                }
                else
                {
                    Debug.Log("스택이 꽉 찼습니다. [저장 실패 : " + i + "]");
                }
            }

            while (!fstack.IsEmpty())
            {
                Debug.Log(fstack.Pop());
            }



            CStack <string> sstack = new CStack <string>(size);

            for (int i = 0; i < 7; i++)
            {
                if (!sstack.IsFull())
                {
                    sstack.Push(i + "번");
                }
                else
                {
                    Debug.Log("스택이 꽉 찼습니다. [저장 실패 : " + i + "]");
                }
            }

            while (!sstack.IsEmpty())
            {
                Debug.Log(sstack.Pop());
            }
        }