示例#1
0
        public void Contains()
        {
            Assert.IsTrue(set.Contains(10));
            Assert.IsTrue(set.Contains(20));
            Assert.IsTrue(set.Contains(30));
            Assert.IsFalse(set.Contains(40));

            set.Add(10);
            Assert.IsTrue(set.Contains(10));
            Assert.IsTrue(set.Contains(20));
            Assert.IsTrue(set.Contains(30));
            Assert.IsFalse(set.Contains(40));
            AssertItemsOrder();

            set.Remove(10);
            Assert.IsFalse(set.Contains(10));
            Assert.IsTrue(set.Contains(30));
            Assert.IsTrue(set.Contains(20));
            Assert.IsFalse(set.Contains(40));
            AssertItemsOrder();

            set[0] = 40;
            Assert.IsFalse(set.Contains(10));
            Assert.IsFalse(set.Contains(30));
            Assert.IsTrue(set.Contains(40));
            Assert.IsTrue(set.Contains(20));
            AssertItemsOrder();

            set.Add(10);
            set[0] = 10;
            Assert.IsTrue(set.Contains(40));
            Assert.IsTrue(set.Contains(20));
            Assert.IsTrue(set.Contains(10));
            AssertItemsOrder();
        }
示例#2
0
        public void RemoveTest()
        {
            var set = new IndexedSet <string>();

            Assert.False(set.Remove("A"));

            set.Add("A");

            Assert.True(set.Remove("A"));
            Assert.Zero(set.Count);
            Assert.False(set.Contains("A"));
        }
 private void IndexedSetRemove()
 {
     for (int i = 0; i < count; i++)
     {
         indexedSet.Remove(data[i]);
     }
 }
 public static void RemoveRaycasters(Pointer3DRaycaster raycaster)
 {
     if (raycasters.Remove(raycaster) && Active)
     {
         instance.DisableRaycaster(raycaster);
     }
 }
        public static void RemoveRaycaster(Pointer3DRaycaster raycaster)
        {
            if (!raycasters.Remove(raycaster))
            {
                return;
            }

            if (!processingRaycasters.Contains(raycaster) && Active)
            {
                Instance.CleanUpRaycaster(raycaster);
            }
        }
示例#6
0
        private static void Test()
        {
            int              tid     = ++threadId;
            Random           rand    = new Random();
            IndexedSet <int> set     = new IndexedSet <int>();
            int              counter = 0;

            while (true)
            {
                set.Clear();
                int           size    = rand.Next(20000);
                HashSet <int> hashSet = new HashSet <int>();
                for (int i = 0; i < size; i++)
                {
                    int x = rand.Next(3000);
                    set.Add(x);
                    hashSet.Add(x);
                }
                int size2 = rand.Next(5000);
                for (int i = 0; i < size2; i++)
                {
                    int x = rand.Next(300);
                    set.Remove(x);
                    hashSet.Remove(x);
                }
                if (set.Count != hashSet.Count)
                {
                    throw new Exception();
                }
                List <int> list = new List <int>(hashSet);
                list.Sort();
                for (int i = 0; i < set.Count; i++)
                {
                    if (set[i] != list[i])
                    {
                        throw new Exception();
                    }
                }
                Console.WriteLine($"{tid} success {++counter}");
            }
        }
示例#7
0
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var set = new IndexedSet <int>();

        Console.SetOut(new System.IO.StreamWriter(Console.OpenStandardOutput())
        {
            AutoFlush = false
        });
        while (n-- > 0)
        {
            var q = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            if (q[0] == 0)
            {
                set.Add(q[1]);
                Console.WriteLine(set.Count);
            }
            else if (q[0] == 1)
            {
                Console.WriteLine(set.Contains(q[1]) ? 1 : 0);
            }
            else if (q[0] == 2)
            {
                set.Remove(q[1]);
            }
            else
            {
                foreach (var x in set.GetItems(x => x >= q[1], x => x <= q[2]))
                {
                    Console.WriteLine(x);
                }
            }
        }
        Console.Out.Flush();
    }
示例#8
0
    static object Solve()
    {
        var(n, qc) = Read2();
        var c  = Read();
        var qs = new bool[qc]
                 .Select((_, id) => { var a = Read(); return(id, l: a[0] - 1, r: a[1] - 1); })
                 .GroupBy(q => q.r)
                 .ToDictionary(g => g.Key, g => g.ToArray());

        // 各色に対して、最も右のインデックス
        var ris = Array.ConvertAll(new bool[n + 1], _ => - 1);
        var set = new IndexedSet <int>();

        var counts = new int[qc];

        for (int i = 0; i < n; i++)
        {
            if (ris[c[i]] != -1)
            {
                set.Remove(ris[c[i]]);
            }
            ris[c[i]] = i;
            set.Add(i);

            if (qs.ContainsKey(i))
            {
                foreach (var(id, l, _) in qs[i])
                {
                    var li = set.GetFirstIndex(x => x >= l);
                    counts[id] = set.Count - li;
                }
            }
        }

        return(string.Join("\n", counts));
    }
示例#9
0
 public static bool RemoveNewPosesListener(INewPoseListener listener)
 {
     return(listeners.Remove(listener));
 }
示例#10
0
 public void RemoveRaycastMethod(IRaycastMethod obj)
 {
     methods.Remove(obj);
 }
示例#11
0
 private void OnTriggerExit(Collider obj)
 {
     stayingColliders.Remove(obj);
 }
 public void RemoveGenerator(IRaySegmentGenerator generator)
 {
     generators.Remove(generator);
 }
示例#13
0
 public static void RemoveRaycasters(Pointer3DRaycaster raycaster)
 {
     raycasters.Remove(raycaster);
 }
示例#14
0
        public override void UpdateDeviceState(IVRModuleDeviceState[] prevState, IVRModuleDeviceStateRW[] currState)
        {
            if (VRSettings.isDeviceActive && VRDevice.isPresent)
            {
                InputTracking.GetNodeStates(m_nodeStateList);
            }

            var rightIndex = INVALID_DEVICE_INDEX;
            var leftIndex  = INVALID_DEVICE_INDEX;

            for (int i = 0, imax = m_nodeStateList.Count; i < imax; ++i)
            {
                uint deviceIndex;
                if (!TryGetNodeDeviceIndex(m_nodeStateList[i], out deviceIndex))
                {
                    continue;
                }

                m_prevExistNodeUids.Remove(m_nodeStateList[i].uniqueID);
                m_currExistNodeUids.Add(m_nodeStateList[i].uniqueID);

                var prevDeviceState = prevState[deviceIndex];
                var currDeviceState = currState[deviceIndex];

                currDeviceState.isConnected = true;

                switch (m_nodeStateList[i].nodeType)
                {
                case VRNode.Head:
                    currDeviceState.deviceClass = VRModuleDeviceClass.HMD;
                    break;

                case VRNode.RightHand:
                    currDeviceState.deviceClass = VRModuleDeviceClass.Controller;
                    rightIndex = deviceIndex;
                    break;

                case VRNode.LeftHand:
                    currDeviceState.deviceClass = VRModuleDeviceClass.Controller;
                    leftIndex = deviceIndex;
                    break;

                case VRNode.GameController:
                    currDeviceState.deviceClass = VRModuleDeviceClass.Controller;
                    break;

                case VRNode.HardwareTracker:
                    currDeviceState.deviceClass = VRModuleDeviceClass.GenericTracker;
                    break;

                case VRNode.TrackingReference:
                    currDeviceState.deviceClass = VRModuleDeviceClass.TrackingReference;
                    break;

                default:
                    currDeviceState.deviceClass = VRModuleDeviceClass.Invalid;
                    break;
                }

                if (!prevDeviceState.isConnected)
                {
                    // FIXME: getting wrong name in Unity 2017.1f1
                    //currDeviceState.serialNumber = InputTracking.GetNodeName(m_nodeStateList[i].uniqueID) ?? string.Empty;
                    currDeviceState.serialNumber    = VRDevice.model + " " + m_nodeStateList[i].uniqueID.ToString("X8");
                    currDeviceState.modelNumber     = VRDevice.model + " " + m_nodeStateList[i].nodeType;
                    currDeviceState.renderModelName = VRDevice.model + " " + m_nodeStateList[i].nodeType;

                    SetupKnownDeviceModel(currDeviceState);
                }

                // update device status
                currDeviceState.isPoseValid = m_nodeStateList[i].tracked;

                var velocity = default(Vector3);
                if (m_nodeStateList[i].TryGetVelocity(out velocity))
                {
                    currDeviceState.velocity = velocity;
                }

                var position = default(Vector3);
                if (m_nodeStateList[i].TryGetPosition(out position))
                {
                    currDeviceState.position = position;
                }

                var rotation = default(Quaternion);
                if (m_nodeStateList[i].TryGetRotation(out rotation))
                {
                    currDeviceState.rotation = rotation;
                }
            }

            m_nodeStateList.Clear();

            if (VRModule.IsValidDeviceIndex(rightIndex))
            {
                var rightCurrState = currState[m_rightIndex];
                var rightPrevState = prevState[m_rightIndex];

                var rightMenuPress    = Input.GetKey(ButtonKeyCode.RMenuPress);
                var rightAButtonPress = Input.GetKey(ButtonKeyCode.RAKeyPress);
                var rightPadPress     = Input.GetKey(ButtonKeyCode.RPadPress);

                var rightMenuTouch    = Input.GetKey(ButtonKeyCode.RMenuTouch);
                var rightAButtonTouch = Input.GetKey(ButtonKeyCode.RAKeyTouch);
                var rightPadTouch     = Input.GetKey(ButtonKeyCode.RPadTouch);
                var rightTriggerTouch = Input.GetKey(ButtonKeyCode.RTriggerTouch);

                var rightTrackpadX = Input.GetAxisRaw(ButtonAxisName.RPadX);
                var rightTrackpadY = Input.GetAxisRaw(ButtonAxisName.RPadY);
                var rightTrigger   = Input.GetAxisRaw(ButtonAxisName.RTrigger);
                var rightGrip      = Input.GetAxisRaw(ButtonAxisName.RGrip);

                rightCurrState.SetButtonPress(VRModuleRawButton.ApplicationMenu, rightMenuPress);
                rightCurrState.SetButtonPress(VRModuleRawButton.A, rightAButtonPress);
                rightCurrState.SetButtonPress(VRModuleRawButton.Touchpad, rightPadPress);
                rightCurrState.SetButtonPress(VRModuleRawButton.Trigger, AxisToPress(rightPrevState.GetButtonPress(VRModuleRawButton.Trigger), rightTrigger, 0.55f, 0.45f));
                rightCurrState.SetButtonPress(VRModuleRawButton.Grip, AxisToPress(rightPrevState.GetButtonPress(VRModuleRawButton.Grip), rightGrip, 0.55f, 0.45f));
                rightCurrState.SetButtonPress(VRModuleRawButton.CapSenseGrip, AxisToPress(rightPrevState.GetButtonPress(VRModuleRawButton.CapSenseGrip), rightGrip, 0.55f, 0.45f));

                rightCurrState.SetButtonTouch(VRModuleRawButton.ApplicationMenu, rightMenuTouch);
                rightCurrState.SetButtonTouch(VRModuleRawButton.A, rightAButtonTouch);
                rightCurrState.SetButtonTouch(VRModuleRawButton.Touchpad, rightPadTouch);
                rightCurrState.SetButtonTouch(VRModuleRawButton.Trigger, rightTriggerTouch);
                rightCurrState.SetButtonTouch(VRModuleRawButton.CapSenseGrip, AxisToPress(rightPrevState.GetButtonTouch(VRModuleRawButton.CapSenseGrip), rightGrip, 0.25f, 0.20f));

                rightCurrState.SetAxisValue(VRModuleRawAxis.TouchpadX, rightTrackpadX);
                rightCurrState.SetAxisValue(VRModuleRawAxis.TouchpadY, rightTrackpadY);
                rightCurrState.SetAxisValue(VRModuleRawAxis.Trigger, rightTrigger);
                rightCurrState.SetAxisValue(VRModuleRawAxis.CapSenseGrip, rightGrip);
            }

            if (VRModule.IsValidDeviceIndex(leftIndex))
            {
                var leftCurrState = currState[m_leftIndex];
                var leftPrevState = prevState[m_leftIndex];

                var leftMenuPress    = Input.GetKey(ButtonKeyCode.LMenuPress);
                var leftAButtonPress = Input.GetKey(ButtonKeyCode.LAKeyPress);
                var leftPadPress     = Input.GetKey(ButtonKeyCode.LPadPress);

                var leftMenuTouch    = Input.GetKey(ButtonKeyCode.LMenuTouch);
                var leftAButtonTouch = Input.GetKey(ButtonKeyCode.LAKeyTouch);
                var leftPadTouch     = Input.GetKey(ButtonKeyCode.LPadTouch);
                var leftTriggerTouch = Input.GetKey(ButtonKeyCode.LTriggerTouch);

                var leftTrackpadX = Input.GetAxisRaw(ButtonAxisName.LPadX);
                var leftTrackpadY = Input.GetAxisRaw(ButtonAxisName.LPadY);
                var leftTrigger   = Input.GetAxisRaw(ButtonAxisName.LTrigger);
                var leftGrip      = Input.GetAxisRaw(ButtonAxisName.LGrip);

                leftCurrState.SetButtonPress(VRModuleRawButton.ApplicationMenu, leftMenuPress);
                leftCurrState.SetButtonPress(VRModuleRawButton.A, leftAButtonPress);
                leftCurrState.SetButtonPress(VRModuleRawButton.Touchpad, leftPadPress);
                leftCurrState.SetButtonPress(VRModuleRawButton.Trigger, AxisToPress(leftPrevState.GetButtonPress(VRModuleRawButton.Trigger), leftTrigger, 0.55f, 0.45f));
                leftCurrState.SetButtonPress(VRModuleRawButton.Grip, AxisToPress(leftPrevState.GetButtonPress(VRModuleRawButton.Grip), leftGrip, 0.55f, 0.45f));
                leftCurrState.SetButtonPress(VRModuleRawButton.CapSenseGrip, AxisToPress(leftPrevState.GetButtonPress(VRModuleRawButton.CapSenseGrip), leftGrip, 0.55f, 0.45f));

                leftCurrState.SetButtonTouch(VRModuleRawButton.ApplicationMenu, leftMenuTouch);
                leftCurrState.SetButtonTouch(VRModuleRawButton.A, leftAButtonTouch);
                leftCurrState.SetButtonTouch(VRModuleRawButton.Touchpad, leftPadTouch);
                leftCurrState.SetButtonTouch(VRModuleRawButton.Trigger, leftTriggerTouch);
                leftCurrState.SetButtonTouch(VRModuleRawButton.CapSenseGrip, AxisToPress(leftPrevState.GetButtonTouch(VRModuleRawButton.CapSenseGrip), leftGrip, 0.25f, 0.20f));

                leftCurrState.SetAxisValue(VRModuleRawAxis.TouchpadX, leftTrackpadX);
                leftCurrState.SetAxisValue(VRModuleRawAxis.TouchpadY, leftTrackpadY);
                leftCurrState.SetAxisValue(VRModuleRawAxis.Trigger, leftTrigger);
                leftCurrState.SetAxisValue(VRModuleRawAxis.CapSenseGrip, leftGrip);
            }

            // remove disconnected nodes
            for (int i = m_prevExistNodeUids.Count - 1; i >= 0; --i)
            {
                if (currState[i].isConnected)
                {
                    currState[i].Reset();
                }
                RemoveNodeDeviceIndex(m_prevExistNodeUids[i]);
            }

            var temp = m_prevExistNodeUids;

            m_prevExistNodeUids = m_currExistNodeUids;
            m_currExistNodeUids = temp;
            m_currExistNodeUids.Clear();

            if (m_rightIndex != rightIndex || m_leftIndex != leftIndex)
            {
                m_rightIndex = rightIndex;
                m_leftIndex  = leftIndex;
                InvokeControllerRoleChangedEvent();
            }
        }
 /// <summary>
 /// Remove a Graphic to the list of tracked Graphics
 /// </summary>
 /// <param name="g">The graphic to remove from tracking.</param>
 public static void UnTrackGraphic(Graphic g)
 {
     m_Tracked.Remove(g);
 }
 public virtual void RemoveElement(BaseCurved3DElement element)
 {
     m_elements.Remove(element);
 }
 public static bool RemoveTarget(ICanvasRaycastTarget obj)
 {
     return(obj == null ? false : canvases.Remove(obj));
 }
示例#18
0
 public void Remove(int atIndex)
 {
     PreRemoved?.Invoke(atIndex);
     mIndexedSet.Remove(atIndex);
     PostRemoved?.Invoke(atIndex);
 }
示例#19
0
        public void RefreshSelectedRoleBindings()
        {
            var roleMap      = m_roleSetButtonList[m_selectedRoleIndex].roleMap;
            var bindingTable = roleMap.BindingTable;

            // update bound device list and keep the original order
            for (int i = 0, imax = m_boundDevices.Count; i < imax; ++i)
            {
                m_tempDevices.Add(m_boundDevices[i]);
            }
            for (int i = 0, imax = bindingTable.Count; i < imax; ++i)
            {
                var boundDevice = bindingTable.GetKeyByIndex(i);
                if (!m_tempDevices.Remove(boundDevice))
                {
                    m_boundDevices.Add(boundDevice);
                }
            }
            for (int i = 0, imax = m_tempDevices.Count; i < imax; ++i)
            {
                m_boundDevices.Remove(m_tempDevices[i]);
            }
            m_tempDevices.Clear();

            if (m_bindingList.Count == 0)
            {
                m_bindingList.Add(m_bindingItem);
                m_bindingItem.onEditPress   += StartEditBinding;
                m_bindingItem.onRemovePress += RemoveBinding;
            }

            var bindingIndex = 0;

            for (int max = m_boundDevices.Count; bindingIndex < max; ++bindingIndex)
            {
                BindingInterfaceRoleSetBindingItem item;
                if (bindingIndex >= m_bindingList.Count)
                {
                    var itemObj = Instantiate(m_bindingItem.gameObject);
                    itemObj.transform.SetParent(m_bindingItem.transform.parent, false);

                    // set child index to secnd last, last index is for add item
                    itemObj.transform.SetSiblingIndex(itemObj.transform.parent.childCount - 2);

                    m_bindingList.Add(item = itemObj.GetComponent <BindingInterfaceRoleSetBindingItem>());
                    item.onEditPress      += StartEditBinding;
                    item.onRemovePress    += RemoveBinding;
                }
                else
                {
                    item = m_bindingList[bindingIndex];
                }

                item.gameObject.SetActive(true);
                item.deviceSN     = m_boundDevices[bindingIndex];
                item.isEditing    = isEditing && item.deviceSN == m_editingDevice;
                item.isHeighLight = hasHeightLight && item.deviceSN == m_heighLightDevice;
                item.RefreshDisplayInfo(roleMap);
            }

            // FIXME: issue in 2017.2.0b2, item won't refresh at the first time, force refresh
            m_bindingItem.transform.parent.gameObject.SetActive(false);
            m_bindingItem.transform.parent.gameObject.SetActive(true);

            for (int max = m_bindingList.Count; bindingIndex < max; ++bindingIndex)
            {
                m_bindingList[bindingIndex].gameObject.SetActive(false);
            }
        }
 protected virtual void OnTriggerExit(Collider collider)
 {
     hoveredColliders.Remove(collider);
 }