//File: CosCollection.idl
//This is the single module for the Collection Service

#ifndef _COS_COLLECTION_IDL_
#define _COS_COLLECTION_IDL_
#pragma prefix "omg.org"

#include <orb.idl>

module CosCollection 
{ 
    interface Collection;

    //  T y p e   d e f i n i t i o n s

    typedef sequence<any> AnySequence;
    typedef string Istring;
    struct NVPair {
	Istring name; 
	any value;
    };
    typedef sequence<NVPair> ParameterList; 

    //  E x c e p t i o n s
    exception  EmptyCollection{};
    exception  PositionInvalid{};

    enum IteratorInvalidReason {is_invalid, 
				is_not_for_collection,  
				is_const};

    exception IteratorInvalid {IteratorInvalidReason why;};
    exception IteratorInBetween{};
    enum ElementInvalidReason {	element_type_invalid, 
				positioning_property_invalid, 
				element_exists};

    exception ElementInvalid {ElementInvalidReason why;};
    exception KeyInvalid {};
    exception ParameterInvalid {unsigned long which; Istring why;}; 


    // O p e r a t i o n s
    interface Operations {

	//  e l e m e n t   t y p e   s p e c i f i c   
	//    i n f o r m a t i o n
	readonly attribute CORBA::TypeCode element_type;
	boolean check_element_type (in any element);
	boolean equal (in any element1, in any element2);
	long compare (in any element1, in any element2);
	unsigned long hash (in any element, in unsigned long value);

	//  k e y   r e t r i e v a l
	any key (in any element);
		
	//  k e y   t y p e   s p e c i f i c   
	//    i n f o r m a t i o n
	readonly attribute CORBA::TypeCode key_type;
	boolean check_key_type (in any key);
	boolean key_equal (in any key1, in any key2);
	long key_compare (in any key1, in any key2);
	unsigned long key_hash (in any thisKey, 
				in unsigned long value);
		
	//  d e s t r o y i n g
	void destroy();
		
    };

    interface Command {
	boolean do_on (in any element);
    };

    interface Comparator { 
	long compare (in any element1, in any element2);
    };



    // Iterators

    // I t e r a t o r
    interface Iterator { 

	//  m o v i n g   i t e r a t o r s
	boolean set_to_first_element ();
	boolean set_to_next_element() raises (IteratorInvalid);
	boolean set_to_next_nth_element (in unsigned long n)
	    raises  (IteratorInvalid); 

	//  r e t r i e v i n g   e l e m e n t s
	boolean retrieve_element (out any element)
	    raises (IteratorInvalid,  IteratorInBetween);
	boolean retrieve_element_set_to_next (	
					      out any element, 
					      out boolean  more)
	    raises (IteratorInvalid, IteratorInBetween);
	boolean retrieve_next_n_elements (	
					  in unsigned long n, 
					  out AnySequence result, 
					  out boolean more)
	    raises (IteratorInvalid,  IteratorInBetween); 
	boolean not_equal_retrieve_element_set_to_next (
							in  Iterator test,  
							out any element)
	    raises (IteratorInvalid, IteratorInBetween); 

	//   r e m o v i n g   e l e m e n t s
	void remove_element() 
	    raises (IteratorInvalid, IteratorInBetween);
	boolean remove_element_set_to_next()
	    raises (IteratorInvalid,  IteratorInBetween); 
	boolean remove_next_n_elements (
					in  unsigned long n, 
					out unsigned long actual_number)
	    raises (IteratorInvalid, IteratorInBetween); 
	boolean not_equal_remove_element_set_to_next (in Iterator test)
	    raises (IteratorInvalid, IteratorInBetween); 
		
	//  r e p l a c i n g   e l e m e n t s
	void replace_element (in any element)
	    raises (IteratorInvalid, IteratorInBetween, ElementInvalid);
	boolean replace_element_set_to_next (in any element)
	    raises(IteratorInvalid, IteratorInBetween, ElementInvalid);
	boolean replace_next_n_elements (
					 in  AnySequence   elements, 
					 out unsigned long actual_number)
	    raises (IteratorInvalid, IteratorInBetween, ElementInvalid); 
	boolean not_equal_replace_element_set_to_next (
						       in Iterator test, 
						       in any element)
	    raises(IteratorInvalid, IteratorInBetween, ElementInvalid); 
		
	//   a d d i n g   e l e m e n t s
	boolean add_element_set_iterator (in any element)raises  
	    (ElementInvalid); 
	boolean add_n_elements_set_iterator (
					     in  AnySequence elements, 
					     out unsigned long actual_number)
	    raises (ElementInvalid);
		
	//  s e t t i n g   i t e r a t o r   s t a t e
	void invalidate (); 
		
	//  t e s t i n g   i t e r a t o r s
	boolean is_valid ();
	boolean is_in_between ();
	boolean is_for(in Collection collector);
	boolean is_const ();
	boolean is_equal (in Iterator test) raises (IteratorInvalid); 
		
	//  c l o n i n g ,   a s s i g n i n g ,    
	//    d e s t r o y i n g  i t e r a t o r s
	Iterator clone ();
	void assign (in Iterator from_where) raises (IteratorInvalid);
	void destroy (); 
		
    };


    // O r d e r e d I t e r a t o r
    interface OrderedIterator: Iterator {

	//   m o v i n g   i t e r a t o r s
	boolean set_to_last_element ();
	boolean set_to_previous_element() raises (IteratorInvalid);
	boolean set_to_nth_previous_element(in unsigned long n)
	    raises  (IteratorInvalid);
	void set_to_position (in unsigned long position) 
	    raises (PositionInvalid);
		
	//  c o m p u t i n g   i t e r a t o r   p o s i t i o n
	unsigned long position () raises (IteratorInvalid); 
		
	//  r e t r i e v i n g   e l e m e n t s
	boolean retrieve_element_set_to_previous(
						 out any element, 
						 out boolean more)
	    raises (IteratorInvalid, IteratorInBetween);
	boolean retrieve_previous_n_elements (
					      in  unsigned long n, 
					      out AnySequence result, 
					      out boolean more)
	    raises (IteratorInvalid,  IteratorInBetween); 
	boolean not_equal_retrieve_element_set_to_previous (
							    in Iterator  test, 
							    out any element)
	    raises (IteratorInvalid, IteratorInBetween); 

	//   r e m o v i n g   e l e m e n t s
	boolean remove_element_set_to_previous()
	    raises (IteratorInvalid,  IteratorInBetween); 
	boolean remove_previous_n_elements (
					    in  unsigned long n, 
					    out unsigned long actual_number)
	    raises (IteratorInvalid, IteratorInBetween);
	boolean not_equal_remove_element_set_to_previous(
							 in Iterator test)
	    raises (IteratorInvalid, IteratorInBetween); 

	//  r e p l a c i n g   e l e m e n t s
	boolean replace_element_set_to_previous(in any element)
	    raises (IteratorInvalid, IteratorInBetween, ElementInvalid);
	boolean replace_previous_n_elements(
					    in  AnySequence   elements, 
					    out unsigned long actual_number)
	    raises (IteratorInvalid, IteratorInBetween, ElementInvalid); 
	boolean not_equal_replace_element_set_to_previous (
							   in Iterator  test, 
							   in any       element)
	    raises (IteratorInvalid, IteratorInBetween, ElementInvalid); 
		
	//  t e s t i n g   i t e r a t o r s
	boolean is_first ();
	boolean is_last ();
	boolean is_for_same (in Iterator test);
	boolean is_reverse ();

    };


    // S e q u e n t i a l I t e r a t o r
    interface SequentialIterator : OrderedIterator { 

	// adding elements
	boolean add_element_as_next_set_iterator (in any element)
	    raises(IteratorInvalid, ElementInvalid);
	void add_n_elements_as_next_set_iterator(
						 in AnySequence elements)
	    raises(IteratorInvalid, ElementInvalid); 
	boolean add_element_as_previous_set_iterator(in any element)
	    raises(IteratorInvalid, ElementInvalid);
	void add_n_elements_as_previous_set_iterator(
						     in AnySequence  elements)
	    raises(IteratorInvalid, ElementInvalid);

    };


    // K e y I t e r a t o r
    interface KeyIterator : Iterator { 
	//  m o v i n g   t h e   i t e r a t o r s
	boolean set_to_element_with_key (in any key) 
	    raises(KeyInvalid);
	boolean set_to_next_element_with_key (in any key)
	    raises(IteratorInvalid, KeyInvalid);
	boolean set_to_next_element_with_different_key()
	    raises (IteratorInBetween, IteratorInvalid); 
		
	//  r e t r i e v i n g   t h e   k e y s
	boolean retrieve_key (out any key)
	    raises (IteratorInBetween,  IteratorInvalid);
	boolean retrieve_next_n_keys (out AnySequence keys)
	    raises (IteratorInBetween, IteratorInvalid); 
		
    };


    // E q u a l i t y I t e r a t o r
    interface EqualityIterator : Iterator { 

	//  m o v i n g   t h e   i t e r a t o r s
	boolean set_to_element_with_value(in any element) 
	    raises(ElementInvalid);
	boolean set_to_next_element_with_value(in any element)
	    raises (IteratorInvalid, ElementInvalid);
	boolean set_to_next_element_with_different_value()
	    raises (IteratorInBetween, IteratorInvalid);

    };



    // E q u a l i t y K e y I t e r a t o r
    interface EqualityKeyIterator : EqualityIterator, KeyIterator {};

    // S o r t e d I t e r a t o r
    interface SortedIterator : OrderedIterator {};


    //  e n u m e r a t i o n   t y p e   f o r   s p e c i f y i n g   r a n g e s
    enum LowerBoundStyle {equal_lo, greater, greater_or_equal};
    enum UpperBoundStyle {equal_up, less, less_or_equal};

    // K e y S o r t e d I t e r a t o r
    interface KeySortedIterator : KeyIterator, SortedIterator {

	//  m o v i n g   t h e   i t e r a t o r s
	boolean set_to_first_element_with_key (
					       in any             key, 
					       in LowerBoundStyle style)
	    raises(KeyInvalid);
	boolean set_to_last_element_with_key (
					      in any              key, 
					      in UpperBoundStyle  style)
	    raises (KeyInvalid); 
	boolean set_to_previous_element_with_key (in any key)
	    raises(IteratorInvalid, KeyInvalid);
	boolean set_to_previous_element_with_different_key()
	    raises (IteratorInBetween, IteratorInvalid); 
		
	//  r e t r i e v i n g   k e y s
	boolean retrieve_previous_n_keys(out AnySequence keys)
	    raises (IteratorInBetween, IteratorInvalid);

    };


    // E q u a l i t y S o r t e d I t e r a t o r
    interface EqualitySortedIterator : 
	EqualityIterator, SortedIterator  {

	//  m o v i n g   t h e   i t e r a t o r
	boolean set_to_first_element_with_value (
						 in any             element, 
						 in LowerBoundStyle style)
	    raises (ElementInvalid);
	boolean set_to_last_element_with_value (
						in any             element, 
						in UpperBoundStyle style)
	    raises (ElementInvalid); 
	boolean set_to_previous_element_with_value (in any elementally)
	    raises (IteratorInvalid, ElementInvalid);
	boolean set_to_previous_element_with_different_value()
	    raises (IteratorInBetween, IteratorInvalid);

    };


    // E q u a l i t y K e y S o r t e d I t e r a t o r
    interface EqualityKeySortedIterator : 
	EqualitySortedIterator,  KeySortedIterator {};

    // E q u a l i t y S e q u e n t i a l I t e r a t o r
    interface EqualitySequentialIterator : 
	EqualityIterator,  SequentialIterator {

	//  l o c a t i n g   e l e m e n t s
	boolean set_to_first_element_with_value (in any element)
	    raises (ElementInvalid);
	boolean set_to_last_element_with_value (in any element)
	    raises (ElementInvalid);
	boolean set_to_previous_element_with_value (in any element)
	    raises (ElementInvalid);

    };


    interface Collection {
	//   e l e m e n t   t y p e   i n f o r m a t i o n
	readonly attribute CORBA::TypeCode element_type;
		
	// a d d i n g   e l e m e n t s
	boolean add_element (in any element) 
	    raises (ElementInvalid);
	boolean add_element_set_iterator (
					  in any      element, 
					  in Iterator where) 
	    raises (IteratorInvalid, ElementInvalid); 
	void add_all_from (in Collection collector) 
	    raises (ElementInvalid);
		
	//   r e m o v i n g   e l e m e n t s
	void remove_element_at (in Iterator where) 
	    raises (IteratorInvalid,  IteratorInBetween); 
	unsigned long remove_all ();
		
	//  r e p l a c i n g   e l e m e n t s
	void replace_element_at (
				 in Iterator where, 
				 in any      element)
	    raises(IteratorInvalid, IteratorInBetween, ElementInvalid); 
		
	// r e t r i e v i n g   e l e m e n t s
	boolean retrieve_element_at (
				     in  Iterator where, 
				     out any element)
	    raises (IteratorInvalid, IteratorInBetween); 
		
	// i t e r a t i n g   o v e r   t h e   c o l l e c t i o n
	boolean all_elements_do (in Command what) ;
		
	//   i n q u i r i n g   c o l l e c t i o n   
	//       i n f o r m a t i o n 
	unsigned long number_of_elements ();
	boolean is_empty ();
		
	//  d e s t r o y i n g   c o l l e c t i o n
	void destroy(); 
		
	//  c r e a t i n g   i t e r a t o r s
	Iterator create_iterator (in boolean read_only); 

    }; 
	
    //  O r d e r e d C o l l e c t i o n
    interface OrderedCollection: Collection {

	//  r e m o v i n g   e l e m e n t s
	void remove_element_at_position (in unsigned long position)
	    raises  (PositionInvalid);
	void remove_first_element () raises (EmptyCollection);
	void remove_last_element () raises (EmptyCollection); 
		
	//  r e t r i e v i n g   e l e m e n t s
	boolean retrieve_element_at_position (
					      in  unsigned long position, 
					      out any           element)
	    raises (PositionInvalid);
	boolean retrieve_first_element (out any element) 
	    raises  (EmptyCollection);
	boolean retrieve_last_element (out any element) 
	    raises  (EmptyCollection);
		
	//  c r e a t i n g   i t e r a t o r s
	OrderedIterator create_ordered_iterator(
						in boolean read_only, 
						in boolean reverse_iteration);
		
    }; 
	
	
    // S e q u e n t i a l C o l l e c t i o n
    interface SequentialCollection: OrderedCollection {

	//   a d d i n g   e l e m e n t s   
	void add_element_as_first (in any element) 
	    raises (ElementInvalid);
		
	void add_element_as_first_set_iterator (
						in any       element, 
						in Iterator  where)
	    raises (ElementInvalid, IteratorInvalid); 
	void add_element_as_last (in any element) 
	    raises (ElementInvalid);
	void add_element_as_last_set_iterator (
					       in any       element, 
					       in Iterator  where)
	    raises (ElementInvalid, IteratorInvalid); 
	void add_element_as_next (
				  in any      element, 
				  in Iterator where)
	    raises  (ElementInvalid, IteratorInvalid); 
	void add_element_as_previous (
				      in any      element, 
				      in Iterator where)
	    raises (ElementInvalid,IteratorInvalid); 
	void add_element_at_position (
				      in unsigned long position, 
				      in any           element)
	    raises(PositionInvalid, ElementInvalid); 
	void add_element_at_position_set_iterator (
						   in unsigned long  position, 
						   in any            element, 
						   in Iterator       where) 
	    raises  (PositionInvalid, ElementInvalid, IteratorInvalid); 
		
	//  r e p l a c i n g   e l e m e n t s
	void replace_element_at_position (
					  in unsigned long position, 
					  in any           element)
	    raises (PositionInvalid, ElementInvalid);
	void replace_first_element (in any element)
	    raises (ElementInvalid,  EmptyCollection);
	void replace_last_element (in any element) 
	    raises (ElementInvalid,  EmptyCollection); 
		
	//  r e o r d e r i n g   e l e m e n t s
	void sort (in Comparator comparison); void reverse(); 
		
    };
	
	
    // S o r t e C o l l e c t i o n
    interface SortedCollection: OrderedCollection{};
	
    // E q u a l i t y C o l l e c t i o n
    interface EqualityCollection: Collection {

	//  t e s t i n g   e l e m e n t   c o n t a i n m e n t
	boolean contains_element (in any element) 
	    raises(ElementInvalid);
	boolean contains_all_from (in Collection collector)  
	    raises(ElementInvalid); 
		
	//  a d d i n g   e l e m e n t s
	boolean locate_or_add_element (in any element) 
	    raises (ElementInvalid); 
	boolean locate_or_add_element_set_iterator (
						    in any      element, 
						    in Iterator where)
	    raises (ElementInvalid, IteratorInvalid); 
		
	//  l o c a t i n g   e l e m e n t s
	boolean locate_element (
				in any      element, 
				in Iterator where) 
	    raises (ElementInvalid, IteratorInvalid);
	boolean locate_next_element (
				     in any      element, 
				     in Iterator where)
	    raises (ElementInvalid, IteratorInvalid);
	boolean locate_next_different_element (in Iterator where)
	    raises  (IteratorInvalid, IteratorInBetween);
		
	//  r e m o v i n g   e l e m e n t s
	boolean remove_element (in any element) 
	    raises (ElementInvalid);
	unsigned long remove_all_occurrences (in any element)
	    raises (ElementInvalid); 
		
	//  i n q u i r i n g   c o l l e c t i o n   
	//      i n f o r m a t i o n
	unsigned long number_of_different_elements ();
	unsigned long number_of_occurrences (in any element) 
	    raises(ElementInvalid);
		
    };

    // K e y C o l l e c t i o n
    interface KeyCollection: Collection { 

	//  K e y   t y p e   i n f o r m a t i o n
	readonly attribute CORBA::TypeCode key_type; 
		
	//  t e s t i n g   c o n t a i n m e n t
	boolean contains_element_with_key (in any key) 
	    raises(KeyInvalid);
	boolean contains_all_keys_from (in KeyCollection collector)
	    raises(KeyInvalid);
		
	//  a d d i n g   e l e m e n t s
	boolean locate_or_add_element_with_key (in any element)
	    raises(ElementInvalid);
	boolean locate_or_add_element_with_key_set_iterator (
							     in any      element, 
							     in Iterator where)
	    raises (ElementInvalid,  IteratorInvalid);
		
	//  a d d i n g   o r   r e p l a c i n g   e l e m e n t s
	boolean add_or_replace_element_with_key (in any element)
	    raises(ElementInvalid); 
	boolean add_or_replace_element_with_key_set_iterator (
							      in any      element, 
							      in Iterator where)
	    raises (ElementInvalid,  IteratorInvalid); 
		
	//  r e m o v i n g   e l e m e n t s
	boolean remove_element_with_key(in any key) 
	    raises(KeyInvalid);
	unsigned long remove_all_elements_with_key (in any key) 
	    raises(KeyInvalid); 
		
	//  r e p l a c i n g   e l e m e n t s
	boolean replace_element_with_key (in any element) 
	    raises(ElementInvalid);
	boolean replace_element_with_key_set_iterator (
						       in any      element, 
						       in Iterator where)
	    raises (ElementInvalid, IteratorInvalid);
		
	//  r e t r i e v i n g   e l e m e n t s
	boolean retrieve_element_with_key (
					   in  any key, 
					   out any element)
	    raises (KeyInvalid); 
		
	//  c o m p u t i n g   t h e   k e y s
	void key (in any element, out any key) 
	    raises (ElementInvalid);
	void keys (in AnySequence elements, out AnySequence keys)
	    raises (ElementInvalid);
		
	//  l o c a t i n g   e l e m e n t s
	boolean locate_element_with_key (
					 in any      key, 
					 in Iterator where)
	    raises (KeyInvalid, IteratorInvalid);
	boolean locate_next_element_with_key (
					      in any      key, 
					      in Iterator where)
	    raises (KeyInvalid, IteratorInvalid);
	boolean locate_next_element_with_different_key (
							in Iterator where)
	    raises (IteratorInBetween, IteratorInvalid);
		
	//  i n q u i r i n g   c o l l e c t i o n   
	//      i n f o r m a t i o n
	unsigned long number_of_different_keys ();
	unsigned long number_of_elements_with_key (in any key) 
	    raises(KeyInvalid);
		
    };


    // E q u a l i t y K e y C o l l e c t i o n
    interface EqualityKeyCollection : 
	EqualityCollection, KeyCollection{};

    // K e y S o r t e d C o l l e c t i o n
    interface KeySortedCollection : 
	KeyCollection, SortedCollection { 

	//  l o c a t i n g   e l e m e n t s
	boolean locate_first_element_with_key (
					       in any      key, 
					       in Iterator where)
	    raises (KeyInvalid, IteratorInvalid); 
	boolean locate_last_element_with_key(
					     in any      key, 
					     in Iterator where)
	    raises (KeyInvalid, IteratorInvalid);
	boolean locate_previous_element_with_key (
						  in any      key, 
						  in Iterator where)
	    raises (KeyInvalid, IteratorInvalid); 
	boolean locate_previous_element_with_different_key(
							   in Iterator  where)
	    raises (IteratorInBetween, IteratorInvalid);

    };
	
	
    // E q u a l i t y S o r t e d C o l l e c t i o n
    interface EqualitySortedCollection : 
	EqualityCollection,  SortedCollection {
	
	//  l o c a t i n g   e l e m e n t s
	boolean locate_first_element (
				      in any      element, 
				      in Iterator where)
	    raises (ElementInvalid, IteratorInvalid);
	boolean locate_last_element (
				     in any      element, 
				     in Iterator where)
	    raises (ElementInvalid, IteratorInvalid);
	boolean locate_previous_element (
					 in any      element, 
					 in Iterator where)
	    raises  (ElementInvalid, IteratorInvalid);
	boolean locate_previous_different_element (in Iterator where)
	    raises  (IteratorInvalid);

    }; 
	
	
    // E q u a l i t y K e y S o r t e d C o l l e c t i o n
    interface EqualityKeySortedCollection : 
	EqualityCollection, KeyCollection,  SortedCollection {};


    // E q u a l i t y S e q u e n t i a l C o l l e c t i o n
    interface EqualitySequentialCollection : 
	EqualityCollection,  SequentialCollection  {

	//  l o c a t i n g   e l e m e n t s
	boolean locate_first_element_with_value (
						 in any      element, 
						 in Iterator where)
	    raises (ElementInvalid, IteratorInvalid);
	boolean locate_last_element_with_value (
						in any      element, 
						in Iterator where)
	    raises (ElementInvalid, IteratorInvalid);
	boolean locate_previous_element_with_value (
						    in any      element, 
						    in Iterator where)
	    raises (ElementInvalid, IteratorInvalid);
		
    };
	
	
    // THE CONCRETE COLLECTION INTERFACES
	
	
    // K e y S e t
    interface KeySet: KeyCollection {};
	
    // K e y B a g
    interface KeyBag: KeyCollection {};
	
    // M a p
    interface Map : EqualityKeyCollection { 
	
	//  s e t   t h e o r e t i c a l   o p e r a t i o n s
	void difference_with (in Map collector) 
	    raises (ElementInvalid);
	void add_difference (
			     in Map collector1, 
			     in Map collector2) 
	    raises  (ElementInvalid);
	void intersection_with (in Map collector) 
	    raises (ElementInvalid);
	void add_intersection (
			       in Map collector1, 
			       in Map collector2)
	    raises  (ElementInvalid);
	void union_with (in Map collector) 
	    raises (ElementInvalid);
	void add_union (
			in Map collector1, 
			in Map collector2) 
	    raises (ElementInvalid);
		
	//   t e s t i n g   e q u a l i t y
	boolean equal (in Map collector) 
	    raises (ElementInvalid);
	boolean not_equal (in Map collector) 
	    raises(ElementInvalid);
		
    };
	
	
    // R e l a t i o n
    interface Relation : EqualityKeyCollection { 
	
	//  e q u a l ,   n o t _ e q u a l ,   a n d   t h e   
	//  s e t - t h e o r e t i c a l   o p e r a t i o n s   a s   
	//  d e f i n e d   f o r   M a p  
    }; 


    // S e t
    interface Set : EqualityCollection { 
	
	//  e q u a l ,   n o t _ e q u a l ,   a n d   t h e   s e t   
	//  t h e o r e t i c a l   o p e r a t i o n s   a s   
	//  d e f i n e d   f o r   M a p
    }; 
	
	
    // B a g
    interface Bag : EqualityCollection { 
	
	//  e q u a l ,   n o t _ e q u a l ,   a n d   t h e   s e t   
	//  t h e o r e t i c a l   o p e r a t i o n s   a s   d e f i n e d   
	//  d e f i n e d   f o r   M a p
	
    };
	
	
    // K e y S o r t e d S e t
    interface KeySortedSet : KeySortedCollection {
	long compare (	in KeySortedSet collector, 
			in Comparator comparison); 
    };
	
	
    // K e y S o r t e d B a g
    interface KeySortedBag : KeySortedCollection {
	long compare (	in KeySortedBag collector, 
			in Comparator comparison); 
    };


    // S o r t e d M a p
    interface SortedMap : EqualityKeySortedCollection { 
	
	//  e q u a l ,   n o t _ e q u a l ,   a n d   t h e   s e t   
	// t h e o r e t i c a l   o p e r a t i o n s
	long compare (	in SortedMap collector, 
			in Comparator comparison);
    };
	
	
    // S o r t e d R e l a t i o n
    interface SortedRelation : EqualityKeySortedCollection {
	
	//  e q u a l ,   n o t _ e q u a l ,   a n d   t h e   s e t
	//  t h e o r e t i c a l   o p e r a t i o n s
	long compare (	in SortedRelation collector, 
			in Comparator  comparison);
    };
	
	
    // S o r t e d S e t
    interface SortedSet : EqualitySortedCollection {
	
	// e q u a l ,   n o t _ e q u a l ,   a n d   t h e   s e t   
	// t h e o r e t i c a l   o p e r a t i o n s
	long compare (	in SortedSet collector, 
			in Comparator comparison);
    };
	
	
    // S o r t e d B a g
    interface SortedBag: EqualitySortedCollection { 
	
	//  e q u a l ,   n o t _ e q u a l ,   a n d   t h e   s e t
	// t h e o r e t i c a l   o p e r a t i o n s
	long compare (	in SortedBag collector, 
			in Comparator comparison);
    };
	
	
    // S e q u e n c e
    interface CSequence : SequentialCollection { 
	//  C o m p a r i s o n
	long compare (	in CSequence collector, 
			in Comparator comparison);
    };


    // E q u a l i t y S e q u e n c e
    interface EqualitySequence : EqualitySequentialCollection { 
	
	//  t e s t   o n   e q u a l i t y
	boolean equal     (in EqualitySequence collector);
	boolean not_equal (in EqualitySequence collector); 
	//   c o m p a r i s o n
	long compare (     in EqualitySequence collector, 
			   in Comparator       comparison);
    };
	
	
    // H e a p
    interface Heap : Collection {};


    //  R e s t r i c t e d   A c c e s s   C o l l e c t i o n s 

    interface RestrictedAccessCollection {

	//  g e t t i n g   i n f o r m a t i o n   o n   
	//      c o l l e c t i o n   s t a t e   
	boolean unfilled ();
	unsigned long size ();
		
	//  r e m o v i n g   e l e m e n t s
	void purge ();
    };


    // Q u e u e
    interface Queue : RestrictedAccessCollection {
	
	//  a d d i n g   e l e m e n t s
	void enqueue (in any element) raises (ElementInvalid);
		
	//   r e m o v i n g   e l e m e n t s
	void dequeue () raises (EmptyCollection);
	boolean element_dequeue (out any element) 
	    raises (EmptyCollection);
    }; 
	
	
    // D e q u e
    interface Deque : RestrictedAccessCollection {
	
	//  a d d i n g   e l e m e n t s
	void enqueue_as_first (in any element) 
	    raises (ElementInvalid);
	void enqueue_as_last (in any element) 
	    raises(ElementInvalid);
	
	//  r e m o v i n g   e l e m e n t s
	void dequeue_first () raises (EmptyCollection);
	boolean element_dequeue_first (out any element) 
	    raises (EmptyCollection);
	void dequeue_last () raises (EmptyCollection);
	boolean element_dequeue_last (out any element) 
	    raises (EmptyCollection);
	
    };


    // S t a c k
    interface Stack: RestrictedAccessCollection {

	//  a d d i n g   e l e m e n t s
	void push (in any element) raises (ElementInvalid);
		
	//  r e m o v i n g   a n d   r e t r i e v i n g   
	//      e l e m e n t s
	void pop () raises (EmptyCollection);
	boolean element_pop (out any element) 
	    raises (EmptyCollection);
	boolean top (out any element) 
	    raises (EmptyCollection);
    };


    // P r i o r i t y Q u e u e
    interface PriorityQueue: RestrictedAccessCollection {
	//  a d d i n g   e l e m e n t s
	void enqueue (in any element) raises (ElementInvalid);
	
	//  r e m o v i n g   e l e m e n t s
	void dequeue () raises (EmptyCollection);
	boolean element_dequeue (out any element) 
	    raises (EmptyCollection);
    };


    // COLLECTION FACTORIES

    // C o l l e c t i o n F a c t o r y
    interface CollectionFactory { 
	Collection generic_create (in ParameterList parameters)
	    raises (ParameterInvalid); 
    };


    // C o l l e c t i o n F a c t o r i e s
    interface CollectionFactories : CollectionFactory { 
	boolean add_factory (
			     in Istring            collection_interface, 
			     in Istring            impl_category, 
			     in Istring            impl_interface, 
			     in CollectionFactory  _factory);
	boolean remove_factory (
				in Istring collection_interface, 
				in Istring impl_category, 
				in Istring impl_interface); 
	Collection create (in ParameterList parameters) 
	    raises (ParameterInvalid);
    }; 


    // R A C o l l e c t i o n F a ct o r y
    interface RACollectionFactory { 
	RestrictedAccessCollection generic_create (
						   in ParameterList  parameters)
	    raises (ParameterInvalid); 
    };


    // R A C o l l e c t i o n F a c t o r i e s
    interface RACollectionFactories : RACollectionFactory {
	boolean add_factory (
			     in Istring              collection_interface, 
			     in Istring              impl_category, 
			     in Istring              impl_interface, 
			     in RACollectionFactory  _factory); 
	boolean remove_factory (
				in Istring collection_interface, 
				in Istring impl_category, 
				in Istring impl_interface); 
	Collection create ( in ParameterList parameters) 
	    raises (ParameterInvalid);
    }; 


    // K e y S e t F a c t o r y
    interface KeySetFactory : CollectionFactory { 
	KeySet create (	in Operations    ops, 
			in unsigned long expected_size);
    };

    // K e y B a g F a c t o r y
    interface KeyBagFactory : CollectionFactory {
	KeyBag create ( in Operations    ops, 
			in unsigned long expected_size);
    };


    // M a p F a c t o r y
    interface MapFactory : CollectionFactory { 
	Map create (in Operations    ops, 
		    in unsigned long expected_size);
    };


    // R e l a t i o n F a c t o r y
    interface RelationFactory : CollectionFactory { 
	Relation create (	in Operations    ops, 
				in unsigned long expected_size);
    };


    // S e t F a c t o r y
    interface SetFactory : CollectionFactory {
	Set create (in Operations ops, 
		    in unsigned long expected_size);
    };


    // B a g F a c t o r y
    interface BagFactory {
	Bag create (in Operations ops, 
		    in unsigned long expected_size);
    };


    // K e y S o r t e d S e t F a c t o r y
    interface KeySortedSetFactory { 
	KeySortedSet create (in Operations    ops, 
			     in unsigned long expected_size);
    };


    // K e y S o r t e d B a g F a c t o r y
    interface KeySortedBagFactory : CollectionFactory {
	KeySortedBag create (in Operations    ops, 
			     in unsigned long expected_size);
    }; 


    // S o r t e d M a p F a c t o r y
    interface SortedMapFactory : CollectionFactory {
	SortedMap create (in Operations    ops, 
			  in unsigned long expected_size);
    };


    // S o r t e d R e l a t i o n F a c t o r y
    interface SortedRelationFactory : CollectionFactory {
	SortedRelation create (	in Operations    ops, 
				in unsigned long expected_size);
    };


    // S o r t e d S e t F a c t o r y
    interface SortedSetFactory : CollectionFactory {
	SortedSet create (	in Operations    ops, 
				in unsigned long expected_size);
    }; 


    // S o r t e d B a g F a c t o r y
    interface SortedBagFactory { 
	SortedBag create (	in Operations    ops, 
				in unsigned long expected_size);
    };


    // S e q u e n c e F a c t o r y
    interface SequenceFactory : CollectionFactory {
	CSequence create (	in Operations    ops, 
				in unsigned long expected_size);
    };


    // E q u a l i t y S e q u e n c e F a c t o r y
    interface EqualitySequenceFactory : CollectionFactory { 
	EqualitySequence create (in Operations    ops, 
				 in unsigned long expected_size);
    };


    // H e a p F a c t o r y
    interface HeapFactory : CollectionFactory {
	Heap create (in Operations    ops, 
		     in unsigned long expected_size);
    };


    // Q u e u e F a c t o r y
    interface QueueFactory : RACollectionFactory {
	Queue create (	in Operations ops, 
			in unsigned long expected_size);
    };


    // S t a c k F a c t o r y
    interface StackFactory : RACollectionFactory {
	Stack create (	in Operations    ops, 
			in unsigned long expected_size);
    };


    // D e q u e F a c t o r y
    interface DequeFactory : RACollectionFactory { 
	Deque create (	in Operations    ops, 
			in unsigned long expected_size);
    };


    // P r i o r i t y Q u e u e F a c t o r y
    interface PriorityQueueFactory : RACollectionFactory {
	PriorityQueue create (	in Operations    ops, 
				in unsigned long expected_size);
    };

};
#endif /* ifndef _COS_COLLECTION_IDL_ */!
