/*******************************************************************************
 *  Copyright 2017-2018 Centre for Development of Advanced Computing(C-DAC), Pune
 *  
 * Licensed 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 cdac.medinfo.sdk.dcm30_04.utils;

import java.io.Serializable;

/**
 * This interface needs to be implemented by all classes which implements the functionality of Single Collection.
 * This interface provides the user with an abstract interface towards collections holding series of objects.
 * @param <T> object of the type user specifies at the time of instantiation of this interface.
 */
public interface ISingleCollection<T> extends ICollectionIterable<T>, Serializable 
{
	/**
	 * The implementor of this method should provide the mechanism to add the object to the collection .
	 * @param objT object - object of the type user specifies at the time of instantiation of this interface.
	 * @return boolean - returns the status indicating whether the element is added or not .
	 */
	boolean add(T objT);

	/**
	 * The implementation of this method checks the presence of a specified element in the collection.
	 * @param objT object of the type user specifies at the time of instantiation of this interface.
	 * @return boolean - shows status as success or failure.
	 */
	boolean contains(T objT);

	/**
	 * The implementation of this method retrieves the element based on the location.
	 * @param index integer indicating the position of the element to be retrieved from the collection.
	 * @return object - object of the type user specifies at the time of instantiation of this interface .
	 */
	T get(int index);

	/**
	 * The implementation of this method retrieves the size of the collection.
	 * @return int - returns the number of elements present in the collection.
	 */
	int size();

	/**
	 * The implementation of this method retrieves the element based on its index.
	 * @param index index of the element to be retrieved from the collection.
	 * @return T - object retrieved from the collection.
	 */
	T elementAt(int index);

	/**
	 * The implementation of this method retrieves the array from this collection.
	 * @return T[] - returns the array representation of the collection.
	 */
	public T[] toArray();
	
	/**
	 * The implementation of this method removes the element at the specified index.
	 * @param iIndex - position of the element.
	 */
	public void remove(int iIndex);
	
	/**
	 * The implementation of this method removes the element specified from the collection.
	 * @param objT - element to be removed.
	 */
	public void remove(T objT);
	
	/**
	 * The implementation of this method checks that either collection is null or empty.
	 * @return boolean - element to be removed.
	 */
	public boolean isEmpty();
	
	/**
	 * Removes all of the elements from this SingleCollection.
	 * The SingleCollection will be empty after this call returns (unless it throws an exception). 
	 */
	public void clear();
	
}
