コード例 #1
0
        public virtual void TestIteratorGoesForwards()
        {
            IntArrayList list = new IntArrayList();

            AssertIterator(new int[] {  }, list.IntIterator());
            list.Add(1);
            AssertIterator(new int[] { 1 }, list.IntIterator());
            list.Add(2);
            AssertIterator(new int[] { 1, 2 }, list.IntIterator());
        }
コード例 #2
0
ファイル: BlobFileSystemTests.cs プロジェクト: mo5h/omeo
        public void ReuseDeletedFileSpace()
        {
            IntArrayList handles = new IntArrayList();

            for (int i = 0; i < 10; ++i)
            {
                int handle;
                using (BinaryWriter file = _bfs.AllocFile(out handle))
                {
                    handles.Add(handle);
                    for (int j = 0; j < 50; ++j)
                    {
                        file.Write(handle.ToString());
                    }
                }
                using (BinaryWriter file = _bfs.AllocFile(out handle))
                {
                    handles.Add(handle);
                    for (int j = 0; j < 200; ++j)
                    {
                        file.Write(handle.ToString());
                    }
                }
            }
            for (int i = 0; i < 10; ++i)
            {
                _bfs.DeleteFile(handles[(i * 2) + 1]);
            }
            _bfs.Dispose();

            long bsfLength = new FileInfo(_bfsFile).Length;

            SetUp();

            // file handles are reused in back order
            for (int i = 10; i > 0; --i)
            {
                int handle;
                using (BinaryWriter file = _bfs.AllocFile(out handle))
                {
                    Assertion.AssertEquals(handles[(i * 2) - 1], handle);
                    for (int j = 0; j < 200; ++j)
                    {
                        file.Write(handle.ToString());
                    }
                }
            }
            _bfs.Dispose();

            Assert.AreEqual(bsfLength, new FileInfo(_bfsFile).Length);
        }
コード例 #3
0
ファイル: IntArrayListTests.cs プロジェクト: mo5h/omeo
        [Test] public void Enumeration()
        {
            IntArrayList list = new IntArrayList();

            list.Add(1);
            list.Add(654);

            IEnumerator enumerator = list.GetEnumerator();

            Assert.IsTrue(enumerator.MoveNext());
            AssertEquals(1, enumerator.Current);
            Assert.IsTrue(enumerator.MoveNext());
            AssertEquals(654, enumerator.Current);
            Assert.IsTrue(!enumerator.MoveNext());
        }
コード例 #4
0
        //test mthod add(int,int)
        public virtual void TestAddAtIndex()
        {
            IntArrayList list = new IntArrayList();

            for (int i = 0; i < 10; i++)
            {
                list.Add(i);
            }
            list.Add(3, 100);
            Assert.AreEqual(100, list.Get(3));
            for (int i = 4; i < 11; i++)
            {
                Assert.AreEqual(i - 1, list.Get(i));
            }
        }
コード例 #5
0
        Hashtable AddJointsToScene(Scene scn, ElementOrder component)
        {
            if (!joints)
            {
                return(new Hashtable());
            }
            IntArrayList js          = new IntArrayList();
            Hashtable    relationmap = gmdc.LoadJointRelationMap();

            foreach (int k in relationmap.Keys)
            {
                if ((int)relationmap[k] == -1)
                {
                    js.Add(k);
                }
            }

            Quaternion r   = Quaternion.FromRotationMatrix(component.TransformMatrix);
            Vector3f   tmp = r.GetEulerAngles();

            scn.RootJoint.Name = "SIMPE_ROOT_IGNORE";
            //scn.RootJoint.Rotation.X = tmp.X; scn.RootJoint.Rotation.Y = tmp.Y; scn.RootJoint.Rotation.Z = tmp.Z;

            Hashtable jointmap = new Hashtable();

            foreach (int index in js)
            {
                AddJoint(scn.RootJoint, index, jointmap, component);
            }

            return(jointmap);
        }
コード例 #6
0
        /// <summary>
        /// Unserializes a BinaryStream into the Attributes of this Instance
        /// </summary>
        /// <param name="reader">The Stream that contains the FileData</param>
        public void Unserialize(System.IO.BinaryReader reader)
        {
            int vcount = reader.ReadInt32();

            if (vcount > 0)
            {
                try
                {
                    int count = reader.ReadInt32();
                    verts.Clear();
                    for (int i = 0; i < vcount; i++)
                    {
                        Vector3f f = new Vector3f();
                        f.Unserialize(reader);
                        verts.Add(f);
                    }

                    items.Clear();
                    for (int i = 0; i < count; i++)
                    {
                        items.Add(this.ReadValue(reader));
                    }
                }
                catch (Exception ex)
                {
                    Helper.ExceptionMessage("", ex);
                }
            }
        }
コード例 #7
0
ファイル: UserResourceOrder.cs プロジェクト: mo5h/omeo
        /// <summary>
        /// Reads the user sort order from the given resource, in the <b>reverse</b> order.
        /// </summary>
        /// <returns>A list of the resource IDs, in the <b>reverse</b> order.</returns>
        public IntArrayList ReadOrder()
        {
            _resPropertyHolder.Lock();
            try
            {
                // Foolproof checks
                if (_resPropertyHolder.IsDeleted)
                {
                    return(new IntArrayList());
                }
                if (!_resPropertyHolder.HasProp(Core.Props.UserResourceOrder))
                {
                    return(new IntArrayList());
                }

                // Get the byte stream from the saved property
                string          sOrder = _resPropertyHolder.GetStringProp(Core.Props.UserResourceOrder);
                JetMemoryStream ms     = new JetMemoryStream(Convert.FromBase64String(sOrder), true);
                BinaryReader    br     = new BinaryReader(ms);

                // Deserialize the integer IDs
                int          nCount = (int)(br.BaseStream.Length / 4);
                IntArrayList ar     = new IntArrayList(nCount);
                for (int a = 0; a < nCount; a++)
                {
                    ar.Add(br.ReadInt32());
                }
                return(ar);
            }
            finally
            {
                _resPropertyHolder.UnLock();
            }
        }
コード例 #8
0
        /// <summary>
        /// Fills the coordinates and values of cells having non-zero values into the specified lists.
        /// Fills into the lists, starting at index 0.
        /// After this call returns the specified lists all have a new size, the number of non-zero values.
        /// </summary>
        /// <param name="indexList">
        /// The list to be filled with indexes, can have any size.
        /// </param>
        /// <param name="valueList">
        /// The list to be filled with values, can have any size.
        /// </param>
        public override void GetNonZeros(IntArrayList indexList, List <double> valueList)
        {
            bool fillIndexList = indexList != null;
            bool fillValueList = valueList != null;

            if (fillIndexList)
            {
                indexList.Clear();
            }
            if (fillValueList)
            {
                valueList.Clear();
            }
            foreach (var e in Elements)
            {
                if (fillIndexList)
                {
                    indexList.Add(e.Key);
                }
                if (fillValueList)
                {
                    valueList.Add(e.Value);
                }
            }
        }
コード例 #9
0
ファイル: ExportFeedsForm.cs プロジェクト: mo5h/omeo
 private void CollectCheckedResource(IResource res)
 {
     if (_treeFeeds.GetNodeCheckState(res) == CheckBoxState.Checked)
     {
         _listCheckedFeeds.Add(res.Id);
     }
 }
コード例 #10
0
        /// <summary>
        /// Fills the coordinates and values of cells having non-zero values into the specified lists.
        /// Fills into the lists, starting at index 0.
        /// After this call returns the specified lists all have a new size, the number of non-zero values.
        /// <p>
        /// In general, fill order is <i>unspecified</i>.
        /// This implementation fills like: <i>for (index = 0..Count - 1)  do ..d </i>.
        /// However, subclasses are free to us any other order, even an order that may change over time as cell values are changed.
        /// (Of course, result lists indexes are guaranteed to correspond to the same cell).
        /// <p>
        /// <b>Example:</b>
        /// <br>
        /// <pre>
        /// 0, 0, 8, 0, 7
        /// -->
        /// indexList  = (2,4)
        /// valueList  = (8,7)
        /// </pre>
        /// In other words, <i>get(2)==8, get(4)==7</i>.
        /// </summary>
        /// <param name="indexList">the list to be filled with indexes, can have any size.</param>
        /// <param name="valueList">the list to be filled with values, can have any size.</param>
        public void GetNonZeros(ref IntArrayList indexList, ref List <Object> valueList)
        {
            Boolean fillIndexList = indexList != null;
            Boolean fillValueList = valueList != null;

            if (fillIndexList)
            {
                indexList.Clear();
            }
            if (fillValueList)
            {
                valueList.Clear();
            }
            int s = Size;

            for (int i = 0; i < s; i++)
            {
                Object value = this[i];
                if (value != null)
                {
                    if (fillIndexList)
                    {
                        indexList.Add(i);
                    }
                    if (fillValueList)
                    {
                        valueList.Add(value);
                    }
                }
            }
        }
コード例 #11
0
ファイル: ContainersTest.cs プロジェクト: mo5h/omeo
        public void TestIntArrayListReducedCapacity()
        {
            IntArrayList array = new IntArrayList(2);

            for (int i = 0; i < 10; i++)
            {
                array.Add(i);
            }

            //  now artificially reduce amount of memory.
            array.Capacity = 3;
            if (array.Capacity != array.Count)
            {
                throw new ApplicationException("After reducing capacity Count != Capacity" + array.Capacity + " " + array.Count);
            }

            if (array[0] != 0)
            {
                throw new ApplicationException("Elements in the new storage are not saved");
            }
            if (array[1] != 1)
            {
                throw new ApplicationException("Elements in the new storage are not saved");
            }
            if (array.Last != 2)
            {
                throw new ApplicationException("Elements in the new storage are not saved");
            }
        }
コード例 #12
0
        public void Tick()
        {
            itickcount++;
            double squaredvisibilitydistance = 40 * 40;

            if (itickcount > 30)
            {
                itickcount = 0;
                //logfile.WriteLine("EnemyController running static enemy clean" );
                foreach (DictionaryEntry de in unitcontroller.UnitDefByDeployedId)
                {
                    int          unitid         = (int)de.Key;
                    Float3       thispos        = aicallback.GetUnitPos(unitid);
                    IntArrayList enemiestoclean = new IntArrayList();
                    foreach (DictionaryEntry enemyde in EnemyStaticPosByDeployedId)
                    {
                        int    enemyid = (int)enemyde.Key;
                        Float3 pos     = enemyde.Value as Float3;
                        if (Float3Helper.GetSquaredDistance(pos, thispos) < squaredvisibilitydistance)
                        {
                            enemiestoclean.Add(enemyid);
                        }
                    }
                    foreach (int enemyidtoclean in enemiestoclean)
                    {
                        EnemyStaticPosByDeployedId.Remove(enemyidtoclean);
                    }
                }
                if (autoshowenemies)
                {
                    ShowEnemies();
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// Fills the coordinates and values of cells having non-zero values into the specified lists.
        /// Fills into the lists, starting at index 0.
        /// After this call returns the specified lists all have a new size, the number of non-zero values.
        /// </summary>
        /// <param name="indexList">
        /// The list to be filled with indexes, can have any size.
        /// </param>
        /// <param name="valueList">
        /// The list to be filled with values, can have any size.
        /// </param>
        public virtual void GetNonZeros(IntArrayList indexList, List <double> valueList)
        {
            bool fillIndexList = indexList != null;
            bool fillValueList = valueList != null;

            if (fillIndexList)
            {
                indexList.Clear();
            }
            if (fillValueList)
            {
                valueList.Clear();
            }
            int s = Size;

            for (int i = 0; i < s; i++)
            {
                double value = this[i];
                if (value != 0)
                {
                    if (fillIndexList)
                    {
                        indexList.Add(i);
                    }
                    if (fillValueList)
                    {
                        valueList.Add(value);
                    }
                }
            }
        }
コード例 #14
0
        /// <summary>
        /// Fills the coordinates and values of cells having non-zero values into the specified lists.
        /// Fills into the lists, starting at index 0.
        /// After this call returns the specified lists all have a new size, the number of non-zero values.
        /// </summary>
        /// <param name="indexList">
        /// The list to be filled with indexes, can have any size.
        /// </param>
        /// <param name="valueList">
        /// The list to be filled with values, can have any size.
        /// </param>
        public override void GetNonZeros(IntArrayList indexList, List <double> valueList)
        {
            bool fillIndexList = indexList != null;
            bool fillValueList = valueList != null;

            if (fillIndexList)
            {
                indexList.Clear();
            }
            if (fillValueList)
            {
                valueList.Clear();
            }
            AutoParallel.AutoParallelForEach(Elements, (e) =>
            {
                if (fillIndexList)
                {
                    indexList.Add(e.Key);
                }
                if (fillValueList)
                {
                    valueList.Add(e.Value);
                }
            });
        }
コード例 #15
0
ファイル: BlobFileSystem.cs プロジェクト: mo5h/omeo
        /// <summary>
        /// Resturns list of handles of all available files.
        /// </summary>
        /// <returns></returns>
        public IntArrayList GetAllFiles(bool idle)
        {
            int        handle;
            IntHashSet deletedFiles = new IntHashSet();

            handle = _stream.GetFirstFreeFileHandle();
            while (IsValidHandle(handle) && Core.State != CoreState.ShuttingDown &&
                   (!idle || Core.IsSystemIdle))
            {
                deletedFiles.Add(handle);
                ClusteredCachedStream.Cluster cluster = _stream.GetCluster(handle);
                handle = _stream.OffsetToHandle(cluster.NextOffset);
            }
            IntArrayList result = new IntArrayList();

            for (long off = ClusteredCachedStream.BLOB_FILE_SYSTEM_HEADER_SIZE; off < _stream.Length;)
            {
                if (Core.State == CoreState.ShuttingDown || (idle && !Core.IsSystemIdle))
                {
                    break;
                }
                handle = _stream.OffsetToHandle(off);
                ClusteredCachedStream.Cluster cluster = _stream.GetCluster(handle);
                if (cluster.PrevOffset == ClusteredCachedStream.NOT_SET && !deletedFiles.Contains(handle))
                {
                    result.Add(handle);
                }
                off += cluster.Length;
                off += ClusteredCachedStream.CLUSTER_HEADER_SIZE;
            }
            return(result);
        }
コード例 #16
0
        /**
         * Parses the specified property name string into an array of property IDs.
         */

        public int[] PropNamesToIDs(string[] propNames, bool ignoreErrors)
        {
            IntArrayList propIDs = IntArrayListPool.Alloc();

            try
            {
                for (int i = 0; i < propNames.Length; i++)
                {
                    string propName = propNames [i].Trim();

                    if (String.Compare(propName, "DisplayName", true, CultureInfo.InvariantCulture) == 0)
                    {
                        propIDs.Add(ResourceProps.DisplayName);
                    }
                    else if (String.Compare(propName, "Type", true, CultureInfo.InvariantCulture) == 0)
                    {
                        propIDs.Add(ResourceProps.Type);
                    }
                    else
                    {
                        int direction = 1;
                        if (propName.StartsWith("-"))
                        {
                            propName  = propName.Substring(1);
                            direction = -1;
                        }
                        try
                        {
                            propIDs.Add(Core.ResourceStore.GetPropId(propName) * direction);
                        }
                        catch (StorageException)
                        {
                            if (!ignoreErrors)
                            {
                                throw new ArgumentException("Invalid property name " + propName);
                            }
                        }
                    }
                }
                return(propIDs.ToArray());
            }
            finally
            {
                IntArrayListPool.Dispose(propIDs);
            }
        }
コード例 #17
0
ファイル: SingleResourcePredicate.cs プロジェクト: mo5h/omeo
        internal override IntArrayList GetMatchingResources(out bool sortedById)
        {
            sortedById = true;
            IntArrayList result = new IntArrayList(1);

            result.Add(_resource.Id);
            return(result);
        }
コード例 #18
0
ファイル: ICQOptionsPane.cs プロジェクト: mo5h/omeo
        public override void OK()
        {
            IntArrayList uins = IntArrayListPool.Alloc();

            try
            {
                foreach (ListViewItem item in _UINsList.Items)
                {
                    if (item.Checked)
                    {
                        uins.Add((int)item.Tag);
                    }
                }
                uins.Sort();
                bool changed = (uins.Count != _uins.Count);
                if (!changed)
                {
                    for (int i = 0; i < uins.Count; ++i)
                    {
                        if (uins[i] != _uins[i])
                        {
                            changed = true;
                            break;
                        }
                    }
                }
                if (!IsStartupPane)
                {
                    ICQPlugin.SetBuildConverstionOnline(_indexOnlineCheckBox.Checked);
                    ICQPlugin.SetReverseMode(_reverseModeCheckBox.Checked);
                }
                if (!IsStartupPane && _convsTimeSpan.Value != _minutes)
                {
                    ICQPlugin.SetConversationTimeSpan(
                        new TimeSpan(((long)_convsTimeSpan.Value) * 60 * 10000000));
                    changed = true;
                }
                changed = changed ||
                          _importOnly2003bCheckbox.Checked != ICQPlugin.GetImportOnly2003b() ||
                          (_indexOnlineCheckBox.Checked &&
                           _indexOnlineCheckBox.Checked != ICQPlugin.GetBuildConverstionOnline());
                ICQPlugin.SetImportOnly2003b(_importOnly2003bCheckbox.Checked);
                // rebuild conversations if there were changes
                if (changed || IsStartupPane)
                {
                    ICQPlugin.SetUpdateDates(DateTime.MaxValue, DateTime.MinValue);
                    ICQPlugin.SaveUINs2BeIndexed(uins);
                    if (!IsStartupPane)
                    {
                        ICQPlugin.AsyncUpdateHistory();
                    }
                }
            }
            finally
            {
                IntArrayListPool.Dispose(uins);
            }
        }
コード例 #19
0
        public void SetLength(CachedStream owner, long length)
        {
            IntArrayList obsoleteOffsets = null;

            try
            {
                if (owner.Length > length)
                {
                    foreach (CachedPage page in _pagesCache)
                    {
                        if (Object.ReferenceEquals(page.Owner, owner))
                        {
                            if (page.Offset >= length)
                            {
                                if (obsoleteOffsets == null)
                                {
                                    obsoleteOffsets = IntArrayListPool.Alloc();
                                }
                                obsoleteOffsets.Add((int)(page.Offset >> CachedPage._pageShiftBits));
                                page.ClearDirty();
                                if (_lastAccessedPage != null && _lastAccessedPage.Offset == page.Offset)
                                {
                                    _lastAccessedPage = null;
                                }
                            }
                            else if (page.Offset + page.Size > length)
                            {
                                int newSize = (int)(length - page.Offset);
                                if (newSize != page.Size)
                                {
                                    page.Size = newSize;
                                    page.SetDirty();
                                }
                            }
                        }
                    }
                    if (obsoleteOffsets != null)
                    {
                        _searchKey._owner = owner;
                        for (int i = 0; i < obsoleteOffsets.Count; ++i)
                        {
                            _searchKey._offset = obsoleteOffsets[i];
                            _pagesCache.Remove(_searchKey);
                        }
                    }
                }
                owner.SetLengthImpl(length);
            }
            finally
            {
                owner.GetUnderlyingStream().SetLength(length);
                if (obsoleteOffsets != null)
                {
                    IntArrayListPool.Dispose(obsoleteOffsets);
                }
            }
        }
コード例 #20
0
        private static SortSettings LoadSortSettings(IResource res, DisplayColumnProps props)
        {
            IStringList  sortPropList = res.GetStringListProp(props.ColumnSortProps);
            IntArrayList sortProps    = IntArrayListPool.Alloc();

            try
            {
                for (int i = 0; i < sortPropList.Count; i++)
                {
                    string sortPropName = sortPropList [i];
                    if (sortPropName == "DisplayName")
                    {
                        sortProps.Add(ResourceProps.DisplayName);
                    }
                    else if (sortPropName == "Type")
                    {
                        sortProps.Add(ResourceProps.Type);
                    }
                    else if (sortPropName.StartsWith("-"))
                    {
                        sortPropName = sortPropName.Substring(1);
                        if (Core.ResourceStore.PropTypes.Exist(sortPropName))
                        {
                            sortProps.Add(-Core.ResourceStore.PropTypes [sortPropName].Id);
                        }
                    }
                    else
                    {
                        if (Core.ResourceStore.PropTypes.Exist(sortPropName))
                        {
                            sortProps.Add(Core.ResourceStore.PropTypes [sortPropName].Id);
                        }
                    }
                }

                bool sortAsc = res.HasProp(props.ColumnSortAsc);
                return(new SortSettings(sortProps.ToArray(), sortAsc));
            }
            finally
            {
                IntArrayListPool.Dispose(sortProps);
            }
        }
コード例 #21
0
ファイル: ContainersTest.cs プロジェクト: mo5h/omeo
        [Test] public void TestRemoveDuplicates()
        {
            IntArrayList array1 = new IntArrayList();

            array1.RemoveDuplicatesSorted();
            Assert.AreEqual(0, array1.Count);

            IntArrayList array2 = new IntArrayList();

            array2.Add(1);
            array2.RemoveDuplicatesSorted();
            Assert.AreEqual(1, array2.Count);

            IntArrayList array3 = new IntArrayList();

            array3.Add(2);
            array3.Add(2);
            array3.RemoveDuplicatesSorted();
            Assert.AreEqual(1, array3.Count);
        }
コード例 #22
0
        /// <summary>
        /// Read a Link Block
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="items"></param>
        protected void ReadBlock(System.IO.BinaryReader reader, IntArrayList items)
        {
            int count = reader.ReadInt32();

            items.Clear();
            for (int i = 0; i < count; i++)
            {
                items.Add(ReadValue(reader));
            }
            ;
        }
コード例 #23
0
        void AddEnvelopes(GmdcGroup g, Ambertation.Scenes.Mesh m, GmdcElement bonee, GmdcElement bonewighte, Hashtable jointmap)
        {
            if (bonee != null && true)
            {
                int pos = 0;
                foreach (SimPe.Plugin.Gmdc.GmdcElementValueOneInt vi in bonee.Values)
                {
                    byte[]       data = vi.Bytes;
                    IntArrayList used = new IntArrayList();

                    for (int datapos = 0; datapos < 3; datapos++)                 //we can only store 3 bone weights
                    {
                        byte b = data[datapos];
                        if (b != 0xff && b < g.UsedJoints.Count)
                        {
                            int bnr = g.UsedJoints[b];
                            if (used.Contains(bnr))
                            {
                                continue;
                            }


                            used.Add(bnr);
                            Ambertation.Scenes.Joint nj = jointmap[bnr] as Ambertation.Scenes.Joint;
                            if (nj != null)
                            {
                                double w = 1;
                                if (bonewighte != null)
                                {
                                    if (bonewighte.Values.Count > pos)
                                    {
                                        SimPe.Plugin.Gmdc.GmdcElementValueBase v = bonewighte.Values[pos];
                                        if (datapos < v.Data.Length)
                                        {
                                            w = v.Data[datapos];
                                        }
                                    }
                                }

                                //if there is no envelope for nj, make sure we get a new one
                                //with pos 0-Weights inserted
                                Ambertation.Scenes.Envelope e = m.GetJointEnvelope(nj, pos);
                                e.Weights.Add(w);
                                //added = true;
                            }
                        }
                    }

                    pos++;
                    m.SyncEnvelopeLenghts(pos); //fill all unset EnvelopeWeights with 0
                }                               // bonee.Values
            }
        }
コード例 #24
0
        /// <summary>
        /// This Operation will remove all Frames, that are not needed to perform the Animation
        /// </summary>
        /// <remarks>
        /// Unneeded Frames are ones, that can be interpolated by
        /// the previous and following Frame
        /// </remarks>
        public void RemoveUnneededFrames()
        {
            const float DELTA = float.Epsilon * 10;

            for (int blid = this.AxisSet.Length - 1; blid >= 0; blid--)
            {
                IntArrayList remlist = new IntArrayList();
                for (int nr = 1; nr < this.AxisSet[blid].Count - 1; nr++)
                {
                    AnimationAxisTransform iframe = null;

                    /*if (nr==0) iframe = this.AxisSet[blid][nr+1];
                     * else if (nr==this.AxisSet[blid].Count-1) iframe = this.AxisSet[blid][nr+1];
                     * else*/iframe = InterpolateFrame(this.AxisSet[blid][nr - 1], this.AxisSet[blid][nr + 1], this.AxisSet[blid][nr].TimeCode);

                    if (Math.Abs(iframe.Parameter - this.AxisSet[blid][nr].Parameter) < DELTA)
                    {
                        remlist.Add(nr);
                    }
                }


                //sort the List and remove the marked Transformations
                remlist.Sort();
                for (int i = remlist.Count - 1; i >= 0; i--)
                {
                    AxisSet[blid].Remove(AxisSet[blid][remlist[i]]);
                }

                //two or more remaining Frames, where the last two have the same Parameter ==> delete the last one
                if (AxisSet[blid].Count >= 2)
                {
                    if (AxisSet[blid][AxisSet[blid].Count - 2].Parameter == AxisSet[blid][AxisSet[blid].Count - 1].Parameter)
                    {
                        AxisSet[blid].Remove(AxisSet[blid][AxisSet[blid].Count - 1]);
                    }
                }

                //Now set the suggested Type that should be used
                if (AxisSet[blid].Count == 1)
                {
                    if (AxisSet[blid].FirstTimeCode == 0)
                    {
                        AxisSet[blid].Type = AnimationTokenType.TwoByte;
                    }
                }
                else if (AxisSet[blid].Count == 0)
                {
                    ab3 = (AnimationAxisTransformBlock[])Helper.Delete(ab3, AxisSet[blid]);
                }
            }
        }
コード例 #25
0
        protected IntArrayList DoGetResourcesFromResultSet(IResultSet rs, int column)
        {
            IntArrayList result = new IntArrayList();

            using (SafeRecordValueEnumerator enumerator = new SafeRecordValueEnumerator(rs, "PredicateResourceList.DoGetResourcesFromResultSet"))
            {
                while (enumerator.MoveNext())
                {
                    result.Add(enumerator.GetCurrentIntValue(column));
                }
            }
            return(result);
        }
コード例 #26
0
    public static void Main()
    {
        IntArrayList list = new IntArrayList();

        for (int i = 0; i < 25; i++)
        {
            list.Add(i);
        }

        for (int i = 0; i < list.Count; i++)
        {
            Console.Write(list[i] + " ");
        }

        Console.WriteLine();

        try{
            list.Add("Hello World!");
        }catch (ArgumentException ae) {
            Console.WriteLine(ae);
        }
    }
コード例 #27
0
        /**
         * Returns the necessary result for the situation when a resource no longer
         * matches the predicate. In snapshot mode, adds the resource to the snapshot
         * list; otherwise returns the "Removed from list" result.
         */

        protected PredicateMatch CheckSnapshotRemove(int resID)
        {
            if (_snapshot)
            {
                if (_snapshotList == null)
                {
                    _snapshotList = new IntArrayList();
                }
                _snapshotList.Add(resID);
                return(PredicateMatch.Match);
            }
            return(PredicateMatch.Del);
        }
コード例 #28
0
        /// <summary>
        /// Constructs and returns a new <i>selection view</i> that is a matrix holding the cells matching the given condition.
        /// Applies the condition to each cell and takes only those cells where <tt>condition.apply(get(i))</tt> yields <tt>true</tt>.
        /// </summary>
        /// <param name="condition">
        /// The condition to be matched.
        /// </param>
        /// <returns>
        /// The new view.
        /// </returns>
        public virtual DoubleMatrix1D ViewSelection(DoubleProcedure condition)
        {
            var matches = new IntArrayList();

            for (int i = 0; i < Size; i++)
            {
                if (condition(this[i]))
                {
                    matches.Add(i);
                }
            }
            return(ViewSelection(matches.ToArray()));
        }
コード例 #29
0
ファイル: IntArrayListTests.cs プロジェクト: mo5h/omeo
        [Test] public void BasicTests()
        {
            IntArrayList list = new IntArrayList();

            AssertEquals(0, list.Count);

            list.Add(1);
            AssertEquals(1, list.Count);
            AssertEquals(1, list [0]);

            list [0] = 3;
            AssertEquals(3, list [0]);
        }
コード例 #30
0
ファイル: FilterMgrUIHandler.cs プロジェクト: mo5h/omeo
        public DragDropEffects DragOver(IResource targetResource, IDataObject data, DragDropEffects allowedEffect, int keyState)
        {
            if (data.GetDataPresent(typeof(IResourceList)))
            {
                // The resources we're dragging
                IResourceList dragResources = (IResourceList)data.GetData(typeof(IResourceList));

                // Currently, only the Deleted Resources view has a drop handler
                if (!FilterRegistry.IsDeletedResourcesView(targetResource))
                {
                    return(DragDropEffects.None);
                }

                // Collect all the direct and indirect parents of the droptarget; then we'll check to avoid dropping parent on its children
                IntArrayList parentList = IntArrayListPool.Alloc();
                try
                {
                    IResource parent = targetResource;
                    while (parent != null)
                    {
                        parentList.Add(parent.Id);
                        parent = parent.GetLinkProp(Core.Props.Parent);
                    }

                    // Check
                    foreach (IResource res in dragResources)
                    {
                        // Dropping parent over its child?
                        if (parentList.IndexOf(res.Id) >= 0)
                        {
                            return(DragDropEffects.None);
                        }
                        // Cannot delete resource containers this way
                        if ((Core.ResourceStore.ResourceTypes[res.Type].Flags & ResourceTypeFlags.ResourceContainer) != 0)
                        {
                            return(DragDropEffects.None); // Cannot delete containers
                        }
                    }
                    return(DragDropEffects.Move);
                }
                finally
                {
                    IntArrayListPool.Dispose(parentList);
                }
            }
            else
            {
                return(DragDropEffects.None);
            }
        }
コード例 #31
0
        public void Tick()
        {
            itickcount++;
            double squaredvisibilitydistance = 40 * 40;
            if( itickcount > 30 )
            {
                itickcount = 0;
                /*
                foreach (KeyValuePair<int, Float3> kvp in EnemyStaticPosByDeployedId)
                {
                    int enemyid = kvp.Key;
                    Float3 pos = kvp.Value;
                    if (aicallback.GetCurrentFrame() - LosMap.GetInstance().LastSeenFrameCount[pos.x / 16, pos.z / 16] < 30)
                    {

                    }
                }
                 */
                //logfile.WriteLine("EnemyController running static enemy clean" );
                foreach( KeyValuePair<int, IUnitDef> keyvaluepair in unitcontroller.UnitDefByDeployedId )
                {
                    int unitid = keyvaluepair.Key;
                    IUnitDef thisfriendlyunitdef = keyvaluepair.Value;
                    Float3 thispos = aicallback.GetUnitPos( unitid );
                    IntArrayList enemiestoclean = new IntArrayList();
                    foreach (KeyValuePair<int,Float3> kvp in EnemyStaticPosByDeployedId)
                    {
                        int enemyid = kvp.Key;
                        Float3 pos = kvp.Value;
                        if (Float3Helper.GetSquaredDistance(pos, thispos) < thisfriendlyunitdef.losRadius * thisfriendlyunitdef.losRadius * 16 * 16 )
                        {
                            enemiestoclean.Add( enemyid );
                        }
                    }
                    foreach( int enemyidtoclean in enemiestoclean )
                    {
                        EnemyStaticPosByDeployedId.Remove( enemyidtoclean );
                    }
                }
                if( csai.DebugOn )
                {
                    ShowEnemies();
                }
            }
        }
コード例 #32
0
 public void Tick()
 {
     itickcount++;
     double squaredvisibilitydistance = 40 * 40;
     if( itickcount > 30 )
     {
         itickcount = 0;
         //logfile.WriteLine("EnemyController running static enemy clean" );
         foreach( DictionaryEntry de in unitcontroller.UnitDefByDeployedId )
         {
             int unitid = (int)de.Key;
             Float3 thispos = aicallback.GetUnitPos( unitid );
             IntArrayList enemiestoclean = new IntArrayList();
             foreach( DictionaryEntry enemyde in EnemyStaticPosByDeployedId )
             {
                 int enemyid = (int)enemyde.Key;
                 Float3 pos = enemyde.Value as Float3;
                 if( Float3Helper.GetSquaredDistance( pos, thispos ) < squaredvisibilitydistance )
                 {
                     enemiestoclean.Add( enemyid );
                 }
             }
             foreach( int enemyidtoclean in enemiestoclean )
             {
                 EnemyStaticPosByDeployedId.Remove( enemyidtoclean );
             }
         }
         if( autoshowenemies )
         {
             ShowEnemies();
         }
     }
 }