Java Doc for AbstractSequentialList.java in  » 6.0-JDK-Core » Collections-Jar-Zip-Logging-regex » java » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » Collections Jar Zip Logging regex » java.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.util.AbstractSequentialList

AbstractSequentialList
abstract public class AbstractSequentialList extends AbstractList (Code)
This class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a "sequential access" data store (such as a linked list). For random access data (such as an array), AbstractList should be used in preference to this class.

This class is the opposite of the AbstractList class in the sense that it implements the "random access" methods (get(int index), set(int index, E element), add(int index, E element) and remove(int index)) on top of the list's list iterator, instead of the other way around.

To implement a list the programmer needs only to extend this class and provide implementations for the listIterator and size methods. For an unmodifiable list, the programmer need only implement the list iterator's hasNext, next, hasPrevious, previous and index methods.

For a modifiable list the programmer should additionally implement the list iterator's set method. For a variable-size list the programmer should additionally implement the list iterator's remove and add methods.

The programmer should generally provide a void (no argument) and collection constructor, as per the recommendation in the Collection interface specification.

This class is a member of the Java Collections Framework.
author:
   Josh Bloch
author:
   Neal Gafter
version:
   1.42, 05/05/07
See Also:   Collection
See Also:   List
See Also:   AbstractList
See Also:   AbstractCollection
since:
   1.2




Constructor Summary
protected  AbstractSequentialList()
     Sole constructor.

Method Summary
public  voidadd(int index, E element)
     Inserts the specified element at the specified position in this list (optional operation).
public  booleanaddAll(int index, Collection<? extends E> c)
     Inserts all of the elements in the specified collection into this list at the specified position (optional operation).
public  Eget(int index)
     Returns the element at the specified position in this list.

This implementation first gets a list iterator pointing to the indexed element (with listIterator(index)).

public  Iterator<E>iterator()
     Returns an iterator over the elements in this list (in proper sequence).

This implementation merely returns a list iterator over the list.

abstract public  ListIterator<E>listIterator(int index)
     Returns a list iterator over the elements in this list (in proper sequence).
public  Eremove(int index)
     Removes the element at the specified position in this list (optional operation).
public  Eset(int index, E element)
     Replaces the element at the specified position in this list with the specified element (optional operation).

This implementation first gets a list iterator pointing to the indexed element (with listIterator(index)).



Constructor Detail
AbstractSequentialList
protected AbstractSequentialList()(Code)
Sole constructor. (For invocation by subclass constructors, typically implicit.)




Method Detail
add
public void add(int index, E element)(Code)
Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

This implementation first gets a list iterator pointing to the indexed element (with listIterator(index)). Then, it inserts the specified element with ListIterator.add.

Note that this implementation will throw an UnsupportedOperationException if the list iterator does not implement the add operation.
throws:
  UnsupportedOperationException -
throws:
  ClassCastException -
throws:
  NullPointerException -
throws:
  IllegalArgumentException -
throws:
  IndexOutOfBoundsException -




addAll
public boolean addAll(int index, Collection<? extends E> c)(Code)
Inserts all of the elements in the specified collection into this list at the specified position (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in this list in the order that they are returned by the specified collection's iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)

This implementation gets an iterator over the specified collection and a list iterator over this list pointing to the indexed element (with listIterator(index)). Then, it iterates over the specified collection, inserting the elements obtained from the iterator into this list, one at a time, using ListIterator.add followed by ListIterator.next (to skip over the added element).

Note that this implementation will throw an UnsupportedOperationException if the list iterator returned by the listIterator method does not implement the add operation.
throws:
  UnsupportedOperationException -
throws:
  ClassCastException -
throws:
  NullPointerException -
throws:
  IllegalArgumentException -
throws:
  IndexOutOfBoundsException -




get
public E get(int index)(Code)
Returns the element at the specified position in this list.

This implementation first gets a list iterator pointing to the indexed element (with listIterator(index)). Then, it gets the element using ListIterator.next and returns it.
throws:
  IndexOutOfBoundsException -




iterator
public Iterator<E> iterator()(Code)
Returns an iterator over the elements in this list (in proper sequence).

This implementation merely returns a list iterator over the list. an iterator over the elements in this list (in proper sequence)




listIterator
abstract public ListIterator<E> listIterator(int index)(Code)
Returns a list iterator over the elements in this list (in proper sequence).
Parameters:
  index - index of first element to be returned from the listiterator (by a call to the next method) a list iterator over the elements in this list (in propersequence)
throws:
  IndexOutOfBoundsException -



remove
public E remove(int index)(Code)
Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.

This implementation first gets a list iterator pointing to the indexed element (with listIterator(index)). Then, it removes the element with ListIterator.remove.

Note that this implementation will throw an UnsupportedOperationException if the list iterator does not implement the remove operation.
throws:
  UnsupportedOperationException -
throws:
  IndexOutOfBoundsException -




set
public E set(int index, E element)(Code)
Replaces the element at the specified position in this list with the specified element (optional operation).

This implementation first gets a list iterator pointing to the indexed element (with listIterator(index)). Then, it gets the current element using ListIterator.next and replaces it with ListIterator.set.

Note that this implementation will throw an UnsupportedOperationException if the list iterator does not implement the set operation.
throws:
  UnsupportedOperationException -
throws:
  ClassCastException -
throws:
  NullPointerException -
throws:
  IllegalArgumentException -
throws:
  IndexOutOfBoundsException -




www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.