public void SetInIteratorTest() { ExtendedOneWayLinkedListWithHead <int> lista = new ExtendedOneWayLinkedListWithHead <int>(); lista.Add(1); lista.Add(2); lista.Add(3); ListIterator <int> iterator = lista.GetListIterator(); Assert.ThrowsException <System.IndexOutOfRangeException>(() => iterator.Set(8)); while (iterator.HasNext()) { iterator.Next(); iterator.Set(8); } List <int> lista2 = new List <int> { 8, 8, 8 }; Assert.AreEqual(lista2.Count, lista.Count); IEnumerator <int> iterator1 = lista.GetEnumerator(); IEnumerator <int> iterator2 = lista2.GetEnumerator(); while (iterator1.MoveNext() && iterator2.MoveNext()) { Assert.AreEqual(iterator1.Current, iterator2.Current); } }
/// <summary> /// Sorts the complete datamodel according to the following rules: /// <ul> /// <li>Nodes at one level are sorted by name, that is prefix + local name /// <li>Starting at the root node the children and qualifier are sorted recursively, /// which the following exceptions. /// </summary> /// <remarks> /// Sorts the complete datamodel according to the following rules: /// <ul> /// <li>Nodes at one level are sorted by name, that is prefix + local name /// <li>Starting at the root node the children and qualifier are sorted recursively, /// which the following exceptions. /// <li>Sorting will not be used for arrays. /// <li>Within qualifier "xml:lang" and/or "rdf:type" stay at the top in that order, /// all others are sorted. /// </ul> /// </remarks> public virtual void Sort() { // sort qualifier if (HasQualifier()) { Com.Adobe.Xmp.Impl.XMPNode[] quals = (Com.Adobe.Xmp.Impl.XMPNode[])Sharpen.Collections.ToArray(GetQualifier(), new Com.Adobe.Xmp.Impl.XMPNode[GetQualifierLength()]); int sortFrom = 0; while (quals.Length > sortFrom && (XMPConstConstants.XmlLang.Equals(quals[sortFrom].GetName()) || "rdf:type".Equals(quals[sortFrom].GetName()))) { quals[sortFrom].Sort(); sortFrom++; } Arrays.Sort(quals, sortFrom, quals.Length); ListIterator it = qualifier.ListIterator(); for (int j = 0; j < quals.Length; j++) { it.Next(); it.Set(quals[j]); quals[j].Sort(); } } // sort children if (HasChildren()) { if (!GetOptions().IsArray()) { children.Sort(); } for (Iterator it = IterateChildren(); it.HasNext();) { ((Com.Adobe.Xmp.Impl.XMPNode)it.Next()).Sort(); } } }
/// <summary> /// Replaces the element at the specified position in this list with the /// specified element (optional operation). /// /// <para>This implementation first gets a list iterator pointing to the /// indexed element (with <tt>listIterator(index)</tt>). Then, it gets /// the current element using <tt>ListIterator.next</tt> and replaces it /// with <tt>ListIterator.set</tt>. /// /// </para> /// <para>Note that this implementation will throw an /// <tt>UnsupportedOperationException</tt> if the list iterator does not /// implement the <tt>set</tt> operation. /// /// </para> /// </summary> /// <exception cref="UnsupportedOperationException"> {@inheritDoc} </exception> /// <exception cref="ClassCastException"> {@inheritDoc} </exception> /// <exception cref="NullPointerException"> {@inheritDoc} </exception> /// <exception cref="IllegalArgumentException"> {@inheritDoc} </exception> /// <exception cref="IndexOutOfBoundsException"> {@inheritDoc} </exception> public virtual E Set(int index, E element) { try { ListIterator <E> e = ListIterator(index); E oldVal = e.Next(); e.Set(element); return(oldVal); } catch (NoSuchElementException) { throw new IndexOutOfBoundsException("Index: " + index); } }
/// <summary> /// Split up a list of the form /// <code>sasl:mapred@,digest:5f55d66, sasl@[email protected]</code> /// into a list of possible ACL values, trimming as needed /// The supplied realm is added to entries where /// <ol> /// <li>the string begins "sasl:"</li> /// <li>the string ends with "@"</li> /// </ol> /// No attempt is made to validate any of the acl patterns. /// </summary> /// <param name="aclString">list of 0 or more ACLs</param> /// <param name="realm">realm to add</param> /// <returns>a list of split and potentially patched ACL pairs.</returns> public virtual IList <string> SplitAclPairs(string aclString, string realm) { IList <string> list = Lists.NewArrayList(Splitter.On(',').OmitEmptyStrings().TrimResults ().Split(aclString)); ListIterator <string> listIterator = list.ListIterator(); while (listIterator.HasNext()) { string next = listIterator.Next(); if (next.StartsWith(SchemeSasl + ":") && next.EndsWith("@")) { listIterator.Set(next + realm); } } return(list); }
public void Set(E element) { iterator.Set(element); }