Пример #1
0
        public int Max()
        {
            if (stack.Count == 0)
            {
                throw new Exception("no element in stack");
            }
            MaxInfo topMax = maxStack.Peek() as MaxInfo;

            return(topMax.value);
        }
Пример #2
0
        public int Pop()
        {
            if (stack.Count == 0)
            {
                throw new Exception("no element to pop");
            }
            int     top    = Convert.ToInt32(stack.Pop());
            MaxInfo topMax = maxStack.Peek() as MaxInfo;

            if (topMax.value == top)
            {
                --topMax.count;
                if (topMax.count == 0)
                {
                    maxStack.Pop();
                }
            }
            return(top);
        }
Пример #3
0
 public void Push(int value)
 {
     if (stack.Count > 0)
     {
         MaxInfo topMax = maxStack.Peek() as MaxInfo;
         if (topMax.value == value)
         {
             ++topMax.count;
         }
         else if (topMax.value < value)
         {
             maxStack.Push(new MaxInfo(value, 1));
         }
     }
     else
     {
         maxStack.Push(new MaxInfo(value, 1));
     }
     stack.Push(value);
 }
Пример #4
0
    IEnumerator LoadMaxInfo()
    {
        var sourceUrl = (MasterController.Instance.ServerManager.ServerBundleRoot + CurrentAssetInfo.Id + "/maxinfo.json").Replace(" ", "%20");
        WWW www       = new WWW(sourceUrl);

        yield return(www);

        if (www.error == null)
        {
            Debug.Log("data: " + www.text);

            CurrentMaxInfo = MaxInfo.CreateFromJSON(www.text);

            Debug.Log(CurrentMaxInfo.ToString());
            InfoTextArea.text = CurrentMaxInfo.ToString();
        }
        else
        {
            Debug.LogError("WWW error: " + www.error);
        }
    }