All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.umlg.runtime.collection.ocl.OclStdLibBag Maven / Gradle / Ivy

There is a newer version: 2.0.15
Show newest version
package org.umlg.runtime.collection.ocl;

import org.umlg.runtime.collection.UmlgBag;
import org.umlg.runtime.collection.UmlgOrderedSet;
import org.umlg.runtime.collection.UmlgSequence;
import org.umlg.runtime.collection.UmlgSet;

import java.util.Comparator;


public interface OclStdLibBag extends OclStdLibCollection {

	/**
	 * = (bag : Bag(T)) : Boolean
	 * 
	 * True if self and bag contain the same elements, the same number of times.
	 * 		post: result = (self->forAll(elem | self->count(elem) = bag->count(elem)) and
	 * 		bag->forAll(elem | bag->count(elem) = self->count(elem)) )
*/ Boolean equals(UmlgBag bag); /** * union(bag : Bag(T)) : Bag(T) *
	 * The union of self and bag.
	 * 		post: result->forAll( elem | result->count(elem) = self->count(elem) + bag->count(elem))
	 * 		post: self ->forAll( elem | result->count(elem) = self->count(elem) + bag->count(elem))
	 * 		post: bag ->forAll( elem | result->count(elem) = self->count(elem) + bag->count(elem))
	 * 
*/ UmlgBag union(UmlgBag bag); /** * union(set : Set(T)) : Bag(T) *
	 * The union of self and set.
	 * 		post: result->forAll(elem | result->count(elem) = self->count(elem) + set->count(elem))
	 * 		post: self ->forAll(elem | result->count(elem) = self->count(elem) + set->count(elem))
	 * 		post: set ->forAll(elem | result->count(elem) = self->count(elem) + set->count(elem))
	 * 
*/ UmlgBag union(UmlgSet set); /** * intersection(bag : Bag(T)) : Bag(T) *
	 * The intersection of self and bag.
	 * 		post: result->forAll(elem | result->count(elem) = self->count(elem).min(bag->count(elem)) )
	 * 		post: self->forAll(elem | result->count(elem) = self->count(elem).min(bag->count(elem)) )
	 * 		post: bag->forAll(elem | result->count(elem) = self->count(elem).min(bag->count(elem)) )
	 * 
*/ UmlgBag intersection(UmlgBag bag); /** * intersection(bag : Bag(T)) : Bag(T) * The intersection of self and bag. * post: result->forAll(elem | result->count(elem) = self->count(elem).min(bag->count(elem)) ) * post: self->forAll(elem | result->count(elem) = self->count(elem).min(bag->count(elem)) ) * post: bag->forAll(elem | result->count(elem) = self->count(elem).min(bag->count(elem)) ) */ UmlgSet intersection(UmlgSet set); /** * including(object : T) : Bag(T) *
	 * The bag containing all elements of self plus object.
	 * 		post: result->forAll(elem |
	 * 			if elem = object then
	 * 				result->count(elem) = self->count(elem) + 1
	 * 			else
	 * 				result->count(elem) = self->count(elem)
	 * 			endif)
	 * 	 	post: self->forAll(elem |
	 * 			if elem = object then
	 * 				result->count(elem) = self->count(elem) + 1
	 * 			else
	 * 				result->count(elem) = self->count(elem)
	 * 			endif)
	 * 
*/ UmlgBag including(E object); /** * excluding(object : T) : Bag(T) *
	 * The bag containing all elements of self apart from all occurrences of object.
	 * 		post: result->forAll(elem |
	 * 			if elem = object then
	 * 				result->count(elem) = 0
	 * 			else
	 * 				result->count(elem) = self->count(elem)
	 * 			endif)
	 * 		post: self->forAll(elem |
	 * 			if elem = object then
	 * 				result->count(elem) = 0
	 * 			else
	 * 				result->count(elem) = self->count(elem)
	 * 			endif)
	 * 
*/ UmlgBag excluding(E object); /** * count(object : T) : Integer *
	 * The number of occurrences of object in self.
	 * 
*/ @Override int count(E object); /** * asBag() : Bag(T) *
	 * Redefines the Collection operation. A Bag identical to self. This operation exists for convenience reasons.
	 * 		post: result = self
	 * 
*/ @Override UmlgBag asBag(); /** * asSequence() : Sequence(T) *
	 * Redefines the Collection operation. A Sequence that contains all the elements from self, in undefined order.
	 * 		post: result->forAll(elem | self->count(elem) = result->count(elem))
	 * 		post: self ->forAll(elem | self->count(elem) = result->count(elem))
	 * 
*/ @Override UmlgSequence asSequence(); // /** // * asSet() : Set(T) // *
//	 * Redefines the Collection operation. The Set containing all the elements from self, with duplicates removed.
//	 * 		post: result->forAll(elem | self ->includes(elem))
//	 * 		post: self ->forAll(elem | result->includes(elem))
//	 * 
// */ // @Override // UmlgSet asSet(); /** * asOrderedSet() : OrderedSet(T) *
	 * Redefines the Collection operation. An OrderedSet that contains all the elements from self, in undefined order, with
	 * duplicates removed.
	 * 		post: result->forAll(elem | self ->includes(elem))
	 * 		post: self ->forAll(elem | result->includes(elem))
	 * 		post: self ->forAll(elem | result->count(elem) = 1)
	 * 
*/ UmlgOrderedSet asOrderedSet(); /*************************************************** * Iterate goodies ***************************************************/ @Override UmlgBag select(BooleanExpressionEvaluator e); @Override UmlgBag collectNested(BodyExpressionEvaluator e); @Override UmlgBag collect(BodyExpressionEvaluator e); /** * flatten() : Bag(T2) *
     * Redefines the Collection operation. If the element type is not a collection type, this results in the same bag as self. If the
     * element type is a collection type, the result is the bag containing all the elements of all the recursively flattened elements
     * of self.
     * 		post: result = if self.oclType().elementType.oclIsKindOf(CollectionType) then
     * 			self->iterate(c; acc : Bag(T2) = Bag{} |
     * 				acc->union(c->flatten()->asBag() ) )
     * 			else
     * 				self
     * 			endif
     * 
*/ @Override UmlgBag flatten(); //Predefined Iterator Expressions @Override UmlgSequence sortedBy(Comparator e); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy