Example #1
0
 /// <returns>
 /// Returns an iterator for the children.
 /// <em>Note:</em> take care to use it.remove(), as the flag are not adjusted in that case.
 /// </returns>
 public virtual IEnumerator IterateChildren()
 {
     if (children != null)
     {
         return(GetChildren().GetEnumerator());
     }
     else
     {
         return(JavaCollectionsUtil.EmptyIterator());
     }
 }
Example #2
0
 /// <returns>
 /// Returns an iterator for the qualifier.
 /// <em>Note:</em> take care to use it.remove(), as the flag are not adjusted in that case.
 /// </returns>
 public virtual IEnumerator IterateQualifier()
 {
     if (qualifier != null)
     {
         IEnumerator it = GetQualifier().GetEnumerator();
         return(it);
     }
     else
     {
         return(JavaCollectionsUtil.EmptyIterator());
     }
 }
Example #3
0
        public virtual void JavaCollectionsUtilTest()
        {
            IList <int> emptyList = JavaCollectionsUtil.EmptyList <int>();

            Assert.IsEmpty(emptyList);
            Assert.Throws <NotSupportedException>(() => emptyList.Add(10));

            IDictionary <int, int> emptyMap = JavaCollectionsUtil.EmptyMap <int, int>();

            Assert.IsEmpty(emptyMap);
            Assert.Throws <NotSupportedException>(() => { emptyMap[5] = 10; });

            IEnumerator <int> emptyIterator = JavaCollectionsUtil.EmptyIterator <int>();

            Assert.False(emptyIterator.MoveNext());

            IList <int> unmodifiableList = JavaCollectionsUtil.UnmodifiableList <int>(new int[] { 10, 20, 30, 20 }.ToList());

            Assert.Throws <NotSupportedException>(() => unmodifiableList.Insert(0, 20));
            Assert.Throws <NotSupportedException>(() => { unmodifiableList[2] = 50; });
            int test = unmodifiableList[3];

            Assert.Throws <NotSupportedException>(() => JavaCollectionsUtil.Sort(unmodifiableList));

            IDictionary <int, int> unodifiableMap = JavaCollectionsUtil.UnmodifiableMap(new Dictionary <int, int>()
            {
                { 1, 20 },
                { 2, 40 },
                { 70, 80 },
            });

            test = unodifiableMap[2];
            Assert.Throws <KeyNotFoundException>(() => { int temp = unodifiableMap[3]; });
            Assert.Throws <NotSupportedException>(() => { unodifiableMap[11] = 11; });

            IList <int> singletonList = JavaCollectionsUtil.SingletonList(4);

            Assert.AreEqual(4, singletonList[0]);
            Assert.Throws <NotSupportedException>(() => singletonList.Add(9));

            List <int> x = new int[] { 60, 50, 20 }.ToList();

            JavaCollectionsUtil.Sort(x);
            Assert.AreEqual(20, x[0]);
            Assert.AreEqual(60, x[2]);

            x = new int[] { -1, 0, 1 }.ToList();
            JavaCollectionsUtil.Reverse(x);
            Assert.AreEqual(1, x[0]);
            Assert.AreEqual(0, x[1]);
        }
Example #4
0
 /// <summary><inheritDoc/></summary>
 public virtual IEnumerator <IAttribute> GetEnumerator()
 {
     return(JavaCollectionsUtil.EmptyIterator <IAttribute>());
 }