public static System.Collections.Generic.LinkedListNode <int> Insert(System.Collections.Generic.LinkedList <int> myLList, int n)
    {
        System.Collections.Generic.LinkedListNode <int> firstNode = myLList.First;
        System.Collections.Generic.LinkedListNode <int> newNode;

        System.Collections.Generic.LinkedListNode <int> previousNode = null;
        while (firstNode != null)
        {
            if (firstNode.Previous != null)
            {
                previousNode = firstNode.Previous;
            }

            if ((previousNode != null && previousNode.Value <= n && firstNode.Value >= n))
            {
                newNode = myLList.AddAfter(previousNode, n);
                break;
            }
            else if (firstNode.Value >= n && previousNode == null)
            {
                newNode = myLList.AddFirst(n);
                break;
            }
            else if (firstNode.Next == null && firstNode.Value <= n)
            {
                newNode = myLList.AddAfter(firstNode, n);
                break;
            }
            firstNode = firstNode.Next;
        }
        return(firstNode);
    }
Пример #2
0
    public static System.Collections.Generic.LinkedListNode <int> Add(System.Collections.Generic.LinkedList <int> myLList, int n)
    {
        System.Collections.Generic.LinkedListNode <int> node;

        node = myLList.AddFirst(n);

        return(node);
    }
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* New Method: Apply Challenge Data File Info To Challenges
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    private void ApplyChallengeDataFileInfoToChallenges()
    {
        for (int i = 0; i < Target.m_arChallenges.Length; ++i)
        {
            if (Target.m_arChallenges[i] != null)
            {
                Target.CurrentChallengeID = i;
                string path = (Application.dataPath + "/DEBUG STUFF/Challenge Data/" + Target.CurrentChallengeIDAsString + ".txt");
                if (System.IO.File.Exists(path))
                {
                    using (System.IO.StreamReader reader = new System.IO.StreamReader(path))
                    {
                        string[] challengeData = reader.ReadToEnd().Replace("\r", "").Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries);
                        Target.CurrentChallenge.m_oChallengeName.EnglishTranslation = challengeData[0].Replace("ChallengeName=", "");
                        Target.CurrentChallenge.BPM = (float)System.Convert.ToDouble(challengeData[1].Replace("ChallengeBPM=", ""));
                        Target.CurrentChallenge.backingTrackDelayTime = (float)System.Convert.ToDouble(challengeData[4].Replace("BackingDelay=", ""));
#if UNITY_EDITOR
                        Target.CurrentChallenge.iosBPM = Target.CurrentChallenge.BPM;
                        Target.CurrentChallenge.iosBackingTrackDelay = Target.CurrentChallenge.backingTrackDelayTime;
#endif
                        string vol = challengeData[5].Replace("BackingVolume=", "");
                        if (vol != "N/A")
                        {
                            Target.CurrentChallenge.m_oChallengeBackingTrackInfo.m_fMaxVolume = (float)System.Convert.ToDouble(vol);
                        }


                        System.Collections.Generic.LinkedList <GameObject> children = new System.Collections.Generic.LinkedList <GameObject>();
                        while (Target.CurrentChallenge.transform.childCount > 0)
                        {
                            Transform child = Target.CurrentChallenge.transform.GetChild(0);
                            child.parent = null;
                            children.AddLast(child.gameObject);
                        }
                        foreach (GameObject child in children)
                        {
                            DestroyImmediate(child);
                        }
                        for (int j = 7; j < challengeData.Length; ++j)
                        {
                            string[] noteData = challengeData[j].Replace("NoteData=", "").Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);
                            TambourineSoundsManager.SoundTypes eSoundType = (TambourineSoundsManager.SoundTypes)System.Convert.ToInt32(noteData[0]);
                            float fBeatPos = (float)System.Convert.ToDouble(noteData[1]);
                            Target.CurrentChallenge.AddNewChallengeNote(eSoundType, fBeatPos);
                        }

                        EditorUtility.SetDirty(Target.CurrentChallenge);
                    }
                }
                Target.m_arChallenges[i].gameObject.SetActive(false);
            }
        }

        if (Target.m_arChallenges[0] != null)
        {
            Target.m_arChallenges[0].gameObject.SetActive(true);
        }
    }
    public static int Length(System.Collections.Generic.LinkedList <int> myLList)
    {
        int sizeLinked = 0;

        foreach (int item in myLList)
        {
            sizeLinked++;
        }
        return(sizeLinked);
    }
    public static int Sum(System.Collections.Generic.LinkedList <int> myLList)
    {
        int sumElements = 0;

        foreach (int item in myLList)
        {
            sumElements += item;
        }
        return(sumElements);
    }
Пример #6
0
    private void Awake()
    {
        config = new BallConfig(ConfigResourceLoader.inst.loadConfig("Config/ball.xml").ToXml());
        //rotator = ball.addComponent<BallRotator>();
        //rotator.parabolaK = config.parabolaK;
        //rotator.arclineK = config.arclineK;
#if UNITY_EDITOR
        instance      = this;
        logicPosition = new System.Collections.Generic.LinkedList <Vector3?>();
#endif
    }
    // Reset controller
    void reset()
    {
        engine1.CutEngine();
        engine2.CutEngine();
        engine3.CutEngine();
        engine4.CutEngine();

        transform.position = new Vector3(0, 2, 0);
        transform.rotation = new Quaternion();

        m_debugCurrentHeight = new System.Collections.Generic.LinkedList <float>();
        m_debugTargetHeight  = new System.Collections.Generic.LinkedList <float>();
    }
    public static int Run(int[] nums, int limit)
    {
        if (nums == null)
        {
            return(0);
        }

        var maxDeque = new System.Collections.Generic.LinkedList <int>();
        var minDeque = new System.Collections.Generic.LinkedList <int>();

        int res = 1;

        int l = 0;

        // find the longest subarray for every right pointer by shrinking left pointer
        for (int r = 0; r < nums.Length; ++r)
        {
            // update maxDeque with new right pointer
            while (maxDeque.Count != 0 && maxDeque.Last.Value < nums[r])
            {
                maxDeque.RemoveLast();
            }
            maxDeque.AddLast(nums[r]);

            // update minDeque with new right pointer
            while (minDeque.Count != 0 && minDeque.Last.Value > nums[r])
            {
                minDeque.RemoveLast();
            }
            minDeque.AddLast(nums[r]);

            // shrink left pointer if exceed limit
            while (maxDeque.First.Value - minDeque.First.Value > limit)
            {
                if (maxDeque.First.Value == nums[l])
                {
                    maxDeque.RemoveFirst();
                }
                if (minDeque.First.Value == nums[l])
                {
                    minDeque.RemoveFirst();
                }
                ++l;  // shrink it!
            }

            // update res
            res = Math.Max(res, r - l + 1);
        }

        return(res);
    }
 public static int Pop(System.Collections.Generic.LinkedList <int> myLList)
 {
     System.Collections.Generic.LinkedListNode <int> elementeDeleted;
     if (myLList.Count == 0)
     {
         return(0);
     }
     else
     {
         elementeDeleted = myLList.First;
         myLList.RemoveFirst();
         return(elementeDeleted.Value);
     }
 }
Пример #10
0
    public static int FindNode(System.Collections.Generic.LinkedList <int> myLList, int value)
    {
        int valueIndex = 0;

        foreach (int item in myLList)
        {
            if (item == value)
            {
                return(valueIndex);
            }
            valueIndex++;
        }
        return(-1);
    }
    public static int GetNode(System.Collections.Generic.LinkedList <int> myLList, int n)
    {
        int numberIndex = 0;

        foreach (int item in myLList)
        {
            if (numberIndex == n)
            {
                return(item);
            }
            numberIndex++;
        }
        return(0);
    }
Пример #12
0
    public static void Delete(System.Collections.Generic.LinkedList <int> myLList, int index)
    {
        System.Collections.Generic.LinkedListNode <int> node = myLList.First;
        int positionList = 0;

        while (node != null)
        {
            if (positionList == index)
            {
                myLList.Remove(node);
            }
            positionList++;
            node = node.Next;
        }
    }
Пример #13
0
    public static System.Collections.Generic.LinkedList <int> CreatePrint(int size)
    {
        System.Collections.Generic.LinkedList <int> linkedNumbers = new System.Collections.Generic.LinkedList <int>();

        if (size < 0)
        {
            return(linkedNumbers);
        }

        for (int i = 0; i < size; i++)
        {
            linkedNumbers.AddLast(i);
            Console.WriteLine(i);
        }
        return(linkedNumbers);
    }
Пример #14
0
    public void CallDelay(Action callback, float delay)
    {
//        StartCoroutine (delayFunc (callback,delay));
        if (callback != null)
        {
            TimeCallback tc = new TimeCallback();
            tc.ac      = callback;
            tc.time    = Time.time + delay;
            tc.deleted = false;
            if (cdic == null)
            {
                cdic = new System.Collections.Generic.LinkedList <TimeCallback>();
            }
            cdic.AddLast(tc);
            StartCoroutine(delayFunc2(tc));
        }
    }
Пример #15
0
        public static bool TryGetValue <TKey, TValue>(this IDictionary <TKey, LinkedList <TValue> > dict, TKey key, TValue valueToCompare, out LinkedList <TValue> list, out TValue value)
        {
            if (dict.TryGetValue(key, out list))
            {
                foreach (var item in list)
                {
                    if (item.Equals(valueToCompare))
                    {
                        value = item;
                        return(true);
                    }
                }
            }

            value = default(TValue);
            return(false);
        }