11 #include "ConceptInstantHandler.h"
20 //====== LIFECYCLE ========
22 Instant::Instant(std::vector<int>* instant)
24 nTuple=new std::vector<int>();
30 nTuple=new std::vector<int>();
33 Instant::Instant(int size)
35 nTuple= new std::vector<int>();
48 //====== OPERATIONS =======
50 * Add a new concept to the instant
51 * @param indexConcept: index concept that is going
52 * to be added of the new concept added to the instant
56 void Instant::addConcept(int value)
58 nTuple->push_back(value);
60 //======= INQUIRY ===========
62 * Returns the value nTuple
65 std::vector<int>* Instant::getInstant()
70 * Returns the index of the concept that's
71 * in the instant's concept index
72 * @param indexConcept: index of the concept in the instant
73 * @return indexInConcept
75 int Instant::getIndexInConcept(int indexConcept)
77 return (*nTuple)[indexConcept];
81 * returns the number of concepts that the instant has
82 * @return nTuple.size()
84 int Instant::getSize()
86 return nTuple->size();
90 * Compares if the instant given is equals to the nTuple
91 * @param instant: instant for compare
92 * @return true if is equals to the nTuple, false otherwise
94 bool Instant::isEquals(Instant* instant)
96 int sizeInstant=instant->getSize();
98 int sizeThisInstant=getSize();
99 if(sizeInstant==sizeThisInstant)
102 for(i=0;i<sizeThisInstant;i++)
104 int indexi=(*nTuple)[i];
105 int indexInConcept=instant->getIndexInConcept(i);
106 if(indexi!=indexInConcept)
116 //=========== ACCESS ==========
119 * @param instant: the vector that's going to be save in
122 void Instant::setInstant(std::vector<int>* instant)
125 size=instant->size();
129 nTuple->push_back(k);
134 * Change the concept's index saved in the nTuple index (the index
135 * that's is for that concept
136 * @param indexConcept: Concept that's going to change the value
140 void Instant::setConcept(int indexConcept, int index)
142 (*nTuple)[indexConcept]=index;
145 * remove a concept from the instant
146 * @param indexConcept: Concept that's going to be removec
147 * @return true if succesful, false otherwise
150 bool Instant::removeConcept(int indexConcept)
153 std::vector<int>::iterator conceptsIterator=nTuple->begin();
154 int size=nTuple->size();
159 nTuple->erase(conceptsIterator);