Save This Page
Home » mahout-collections-1.0-src » org.apache.mahout.math.list » [javadoc | source]
    1   /**
    2    * Licensed to the Apache Software Foundation (ASF) under one
    3    * or more contributor license agreements. See the NOTICE file
    4    * distributed with this work for additional information
    5    * regarding copyright ownership. The ASF licenses this file
    6    * to you under the Apache License, Version 2.0 (the
    7    * "License"); you may not use this file except in compliance
    8    * with the License. You may obtain a copy of the License at
    9    *
   10    * http://www.apache.org/licenses/LICENSE-2.0
   11    *
   12    * Unless required by applicable law or agreed to in writing,
   13    * software distributed under the License is distributed on an
   14    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   15    * KIND, either express or implied. See the License for the
   16    * specific language governing permissions and limitations
   17    * under the License.
   18    */
   19   /*
   20   Copyright 1999 CERN - European Organization for Nuclear Research.
   21   Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose 
   22   is hereby granted without fee, provided that the above copyright notice appear in all copies and 
   23   that both that copyright notice and this permission notice appear in supporting documentation. 
   24   CERN makes no representations about the suitability of this software for any purpose. 
   25   It is provided "as is" without expressed or implied warranty.
   26   */
   27   package org.apache.mahout.math.list;
   28   
   29   import java.util.Collection;
   30   
   31   /**
   32    Abstract base class for resizable lists holding objects or primitive data types such as <code>int</code>, <code>float</code>, etc.
   33    First see the <a href="package-summary.html">package summary</a> and javadoc <a href="package-tree.html">tree view</a> to get the broad picture.
   34    <p>
   35    <b>Note that this implementation is not synchronized.</b>
   36   
   37    @author wolfgang.hoschek@cern.ch
   38    @version 1.0, 09/24/99
   39    @see      java.util.ArrayList
   40    @see      java.util.Vector
   41    @see      java.util.Arrays
   42    */
   43   public abstract class AbstractObjectList<T> extends AbstractList {
   44   
   45     /**
   46      * Appends all of the elements of the specified Collection to the receiver.
   47      *
   48      * @throws ClassCastException if an element in the collection is not of the same parameter type of the receiver.
   49      */
   50     public void addAllOf(Collection<T> collection) {
   51       this.beforeInsertAllOf(size(), collection);
   52     }
   53   
   54     /**
   55      * Inserts all elements of the specified collection before the specified position into the receiver. Shifts the
   56      * element currently at that position (if any) and any subsequent elements to the right (increases their indices).
   57      *
   58      * @param index      index before which to insert first element from the specified collection.
   59      * @param collection the collection to be inserted
   60      * @throws ClassCastException        if an element in the collection is not of the same parameter type of the
   61      *                                   receiver.
   62      * @throws IndexOutOfBoundsException if <tt>index &lt; 0 || index &gt; size()</tt>.
   63      */
   64     public void beforeInsertAllOf(int index, Collection<T> collection) {
   65       this.beforeInsertDummies(index, collection.size());
   66       this.replaceFromWith(index, collection);
   67     }
   68   
   69     /**
   70      * Replaces the part of the receiver starting at <code>from</code> (inclusive) with all the elements of the specified
   71      * collection. Does not alter the size of the receiver. Replaces exactly <tt>Math.max(0,Math.min(size()-from,
   72      * other.size()))</tt> elements.
   73      *
   74      * @param from  the index at which to copy the first element from the specified collection.
   75      * @param other Collection to replace part of the receiver
   76      * @throws IndexOutOfBoundsException if <tt>index &lt; 0 || index &gt;= size()</tt>.
   77      */
   78     public abstract void replaceFromWith(int from, Collection<T> other);
   79   }

Save This Page
Home » mahout-collections-1.0-src » org.apache.mahout.math.list » [javadoc | source]