コード例 #1
0
ファイル: ShortList.cs プロジェクト: zanhaipeng/npoi
        /// <summary>
        /// Retains only the elements in this list that are Contained in
        /// the specified collection.  In other words, Removes from this
        /// list all the elements that are not Contained in the specified
        /// collection.
        /// </summary>
        /// <param name="c">collection that defines which elements this Set will retain.</param>
        /// <returns>return true if this list Changed as a result of the call.</returns>
        public bool RetainAll(ShortList c)
        {
            bool rval = false;

            for (int j = 0; j < _limit;)
            {
                if (!c.Contains(_array[j]))
                {
                    Remove(j);
                    rval = true;
                }
                else
                {
                    j++;
                }
            }
            return(rval);
        }
コード例 #2
0
        public void TestContains()
        {
            ShortList list = new ShortList();

            for (short j = 0; j < 1000; j += 2)
            {
                list.Add(j);
            }
            for (short j = 0; j < 1000; j++)
            {
                if (j % 2 == 0)
                {
                    Assert.IsTrue(list.Contains(j));
                }
                else
                {
                    Assert.IsTrue(!list.Contains(j));
                }
            }
        }
コード例 #3
0
ファイル: ShortList.cs プロジェクト: ctddjyds/npoi
        /// <summary>
        /// Retains only the elements in this list that are Contained in
        /// the specified collection.  In other words, Removes from this
        /// list all the elements that are not Contained in the specified
        /// collection.
        /// </summary>
        /// <param name="c">collection that defines which elements this Set will retain.</param>
        /// <returns>return true if this list Changed as a result of the call.</returns>
        public bool RetainAll(ShortList c)
        {
            bool rval = false;

            for (int j = 0; j < _limit; )
            {
                if (!c.Contains(_array[j]))
                {
                    Remove(j);
                    rval = true;
                }
                else
                {
                    j++;
                }
            }
            return rval;
        }