//----------------------------------------------------------------------- public override bool Equals(Object obj) { if (obj == this) { return(true); } if (obj is java.util.List <Object> == false) { return(false); } java.util.List <Object> other = (java.util.List <Object>)obj; if (other.size() != size()) { return(false); } java.util.ListIterator <Object> it1 = listIterator(); java.util.ListIterator <Object> it2 = other.listIterator(); while (it1.hasNext() && it2.hasNext()) { Object o1 = it1.next(); Object o2 = it2.next(); if (!(o1 == null ? o2 == null : o1.equals(o2))) { return(false); } } return(!(it1.hasNext() || it2.hasNext())); }
/** * Returns the next object in the list. * <p> * If at the end of the list, returns the first element. * * @return the object after the last element returned * @throws NoSuchElementException if there are no elements in the list */ public Object next() { if (list.isEmpty()) { throw new java.util.NoSuchElementException( "There are no elements for this iterator to loop on"); } if (iterator.hasNext() == false) { reset(); } return(iterator.next()); }
/** * Compare the specified object with this list for equality. This * implementation uses exactly the code that is used to define the * list equals function in the documentation for the * <code>List.equals</code> method. * * @param o Object to be compared to this list */ public override bool Equals(Object o) { // Simple tests that require no synchronization if (o == this) { return(true); } else if (!(o is java.util.List <Object>)) { return(false); } java.util.List <Object> lo = (java.util.List <Object>)o; // Compare the sets of elements for equality if (fast) { java.util.ListIterator <Object> li1 = list.listIterator(); java.util.ListIterator <Object> li2 = lo.listIterator(); while (li1.hasNext() && li2.hasNext()) { Object o1 = li1.next(); Object o2 = li2.next(); if (!(o1 == null ? o2 == null : o1.equals(o2))) { return(false); } } return(!(li1.hasNext() || li2.hasNext())); } else { lock (list) { java.util.ListIterator <Object> li1 = list.listIterator(); java.util.ListIterator <Object> li2 = lo.listIterator(); while (li1.hasNext() && li2.hasNext()) { Object o1 = li1.next(); Object o2 = li2.next(); if (!(o1 == null ? o2 == null : o1.equals(o2))) { return(false); } } return(!(li1.hasNext() || li2.hasNext())); } } }
private bool setNextObject() { // if previousObjectSet, // then we've walked back one step in the // underlying list (due to a hasPrevious() call) // so skip ahead one matching object if (previousObjectSet) { clearPreviousObject(); if (!setNextObject()) { return(false); } else { clearNextObject(); } } while (iterator.hasNext()) { Object obj = iterator.next(); if (predicate.evaluate(obj)) { nextObject = obj; nextObjectSet = true; return(true); } } return(false); }
public override E set(int location, E @object) { java.util.ListIterator <E> it = listIterator(location); if (!it.hasNext()) { throw new System.IndexOutOfRangeException(); } E result = it.next(); it.set(@object); return(result); }
/** * Applies a given attribute to the given range of this string. * * @param attribute * the attribute that will be applied to this string. * @param value * the value of the attribute that will be applied to this * string. * @param start * the start of the range where the attribute will be applied. * @param end * the end of the range where the attribute will be applied. * @throws IllegalArgumentException * if {@code start < 0}, {@code end} is greater than the length * of this string, or if {@code start >= end}. * @throws NullPointerException * if {@code attribute} is {@code null}. */ public void addAttribute(AttributedCharacterIteratorNS.Attribute attribute, System.Object value, int start, int end) { if (null == attribute) { throw new java.lang.NullPointerException(); } if (start < 0 || end > text.Length || start >= end) { throw new java.lang.IllegalArgumentException(); } if (value == null) { return; } java.util.List <IAC_Range> ranges = attributeMap.get(attribute); if (ranges == null) { ranges = new java.util.ArrayList <IAC_Range>(1); ranges.add(new IAC_Range(start, end, value)); attributeMap.put(attribute, ranges); return; } java.util.ListIterator <IAC_Range> it = ranges.listIterator(); while (it.hasNext()) { IAC_Range range = it.next(); if (end <= range.start) { it.previous(); break; } else if (start < range.end || (start == range.end && value.Equals(range.value))) { IAC_Range r1 = null, r3; it.remove(); r1 = new IAC_Range(range.start, start, range.value); r3 = new IAC_Range(end, range.end, range.value); while (end > range.end && it.hasNext()) { range = it.next(); if (end <= range.end) { if (end > range.start || (end == range.start && value.Equals(range.value))) { it.remove(); r3 = new IAC_Range(end, range.end, range.value); break; } } else { it.remove(); } } if (value.Equals(r1.value)) { if (value.Equals(r3.value)) { it.add(new IAC_Range(r1.start <start?r1.start : start, r3.end> end ? r3.end : end, r1.value)); } else { it.add(new IAC_Range(r1.start < start ? r1.start : start, end, r1.value)); if (r3.start < r3.end) { it.add(r3); } } } else { if (value.Equals(r3.value)) { if (r1.start < r1.end) { it.add(r1); } it.add(new IAC_Range(start, r3.end > end ? r3.end : end, r3.value)); } else { if (r1.start < r1.end) { it.add(r1); } it.add(new IAC_Range(start, end, value)); if (r3.start < r3.end) { it.add(r3); } } } return; } } it.add(new IAC_Range(start, end, value)); }
public virtual bool hasNext() { return(iterator.hasNext()); }
//----------------------------------------------------------------------- public bool hasNext() { return(iterator.hasNext()); }
/** * Checks whether there is a previous element. * * @return true if there is a previous element */ public bool hasPrevious() { return(iterator.hasNext()); }
public bool hasNext() { checkMod(); return(iter.hasNext()); }