Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
commons-collections4-4.2-sources.jar - Apache Commons Collections
commons-collections4-4.2-sources.jar is the source JAR file for Apache Commons Collections 4.2, which provides additional collection handling functionalities on top of JDK library.
JAR File Size and Download Location:
JAR name: commons-collections4-4.2-sources.jar Target JDK version: 1.7 Dependency: None File size: 708,599 bytes Release date: 08-Jul-2018 Download: Apache Commons Collections
✍: FYIcenter.com
⏎ org/apache/commons/collections4/iterators/ReverseListIterator.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.collections4.iterators; import java.util.List; import java.util.ListIterator; import org.apache.commons.collections4.ResettableListIterator; /** * Iterates backwards through a List, starting with the last element * and continuing to the first. This is useful for looping around * a list in reverse order without needing to actually reverse the list. * <p> * The first call to <code>next()</code> will return the last element * from the list, and so on. The <code>hasNext()</code> method works * in concert with the <code>next()</code> method as expected. * However, the <code>nextIndex()</code> method returns the correct * index in the list, thus it starts high and reduces as the iteration * continues. The previous methods work similarly. * * @since 3.2 */ public class ReverseListIterator<E> implements ResettableListIterator<E> { /** The list being wrapped. */ private final List<E> list; /** The list iterator being wrapped. */ private ListIterator<E> iterator; /** Flag to indicate if updating is possible at the moment. */ private boolean validForUpdate = true; /** * Constructor that wraps a list. * * @param list the list to create a reversed iterator for * @throws NullPointerException if the list is null */ public ReverseListIterator(final List<E> list) { super(); if (list == null) { throw new NullPointerException("List must not be null."); } this.list = list; iterator = list.listIterator(list.size()); } //----------------------------------------------------------------------- /** * Checks whether there is another element. * * @return true if there is another element */ @Override public boolean hasNext() { return iterator.hasPrevious(); } /** * Gets the next element. * The next element is the previous in the list. * * @return the next element in the iterator */ @Override public E next() { final E obj = iterator.previous(); validForUpdate = true; return obj; } /** * Gets the index of the next element. * * @return the index of the next element in the iterator */ @Override public int nextIndex() { return iterator.previousIndex(); } /** * Checks whether there is a previous element. * * @return true if there is a previous element */ @Override public boolean hasPrevious() { return iterator.hasNext(); } /** * Gets the previous element. * The next element is the previous in the list. * * @return the previous element in the iterator */ @Override public E previous() { final E obj = iterator.next(); validForUpdate = true; return obj; } /** * Gets the index of the previous element. * * @return the index of the previous element in the iterator */ @Override public int previousIndex() { return iterator.nextIndex(); } /** * Removes the last returned element. * * @throws UnsupportedOperationException if the list is unmodifiable * @throws IllegalStateException if there is no element to remove */ @Override public void remove() { if (validForUpdate == false) { throw new IllegalStateException("Cannot remove from list until next() or previous() called"); } iterator.remove(); } /** * Replaces the last returned element. * * @param obj the object to set * @throws UnsupportedOperationException if the list is unmodifiable * @throws IllegalStateException if the iterator is not in a valid state for set */ @Override public void set(final E obj) { if (validForUpdate == false) { throw new IllegalStateException("Cannot set to list until next() or previous() called"); } iterator.set(obj); } /** * Adds a new element to the list between the next and previous elements. * * @param obj the object to add * @throws UnsupportedOperationException if the list is unmodifiable * @throws IllegalStateException if the iterator is not in a valid state for set */ @Override public void add(final E obj) { // the validForUpdate flag is needed as the necessary previous() // method call re-enables remove and add if (validForUpdate == false) { throw new IllegalStateException("Cannot add to list until next() or previous() called"); } validForUpdate = false; iterator.add(obj); iterator.previous(); } /** * Resets the iterator back to the start (which is the * end of the list as this is a reversed iterator) */ @Override public void reset() { iterator = list.listIterator(list.size()); } }
⏎ org/apache/commons/collections4/iterators/ReverseListIterator.java
Or download all of them as a single archive file:
File name: commons-collections4-4.2-sources.jar File size: 708599 bytes Release date: 2018-07-08 Download
⇒ Download and Install commons-collections4-4.1-bin.zip
⇐ What Is commons-collections4-4.2.jar
2023-03-28, 27509👍, 0💬
Popular Posts:
What Is ojdbc5.jar for Oracle 11g R1? ojdbc5.jar for Oracle 11g R1 is the JAR files of ojdbc.jar, JD...
JDK 11 java.naming.jmod is the JMOD file for JDK 11 Naming module. JDK 11 Naming module compiled cla...
Saxon is an open source product available under the Mozilla Public License. It provides implementati...
How to read XML document from socket connections with the socket\DelayedInput.java provided in the A...
ASM is an all purpose Java bytecode manipulation and analysis framework. It can be used to modify ex...