Exemplo n.º 1
0
/**
 Constructor that creates a copy array. Copy constructor
 @param other the target array want to be copied
 */
SortSetArray::SortSetArray (const SortSetArray &other) {
    setArray = new int[832040];
    size = 832041;
    for (int i=0; i < other.getSize(); i++) {
        this->setArray[i] = other.setArray[i];
   }
}
Exemplo n.º 2
0
/**
 Operator overload for !=. give a boolean for whether the two SortSetArray is not equal
 @param bSet the target array that you want to have the content checked
 @retun false if equal, true if not
 */
bool SortSetArray::operator!=(const SortSetArray& bSet)const {
    
    for (int i=0;i < bSet.getSize(); i++) {
        if(this->setArray[i] != bSet.setArray[i]) {
            return false;
        }
    }
    return true;
}
Exemplo n.º 3
0
/**
 Operator overload for -=. It will assign the union array to given array
 @param bSet the target array that you want to have the content combined
 @retun original array with the new content union with the bSet
 */
SortSetArray SortSetArray::operator-=(const SortSetArray& bSet) {
    
    for (int i=0; i < bSet.getSize(); i++) {
        if (bSet.setArray[i] >= 0) {
            this->remove(bSet.setArray[i]);
        }
    }
    return *this;
}
Exemplo n.º 4
0
/**
 Operator overload for -. It will create a returning difference SortSetArray.
 The difference will contain numbers that removes first array to second array
 @param bSet the target array that you want to have the integers removed.
 @retun differenceSet that contains the difference of the two arrays.
 */
SortSetArray SortSetArray::operator-(const SortSetArray& bSet)const {
    SortSetArray differenceSet = *this;
    
    for (int i=0; i < bSet.getSize(); i++) {
        if (bSet.setArray[i] >= 0) {
            differenceSet.remove(bSet.setArray[i]);
        }
    }
    return differenceSet;
}
Exemplo n.º 5
0
/**
 Operator overload for *. It will create a returning intersection SortSetArray.
 The intersection will contain the numbers that appears in both the given arrays.
 @param bSet the target array that you want to have a intersection with.
 @retun intersectionSet that contains the intersection of the two arrays.
 */
SortSetArray SortSetArray::operator*(const SortSetArray& bSet)const {
    
    SortSetArray intersectionSet;
    
    for (int i=0; i < bSet.getSize(); i++) {
        if (bSet.setArray[i] >= 0 && bSet.setArray[i] == this->setArray[i]) {
            intersectionSet.insert(bSet.setArray[i]);
        }
    }
    return intersectionSet;
}
Exemplo n.º 6
0
/**
 Operator overload for +. It will create a returning unionSet SortSetArray.
 The union will contain union of all numbers in the two arrays.
 @param bSet the target array that you want to have a union with.
 @retun unionSet that contains the union of the two arrays.
 */
SortSetArray SortSetArray::operator+(const SortSetArray& bSet)const {

    SortSetArray unionSet = *this;
    
    for (int i=0; i < bSet.getSize(); i++) {
        if (bSet.setArray[i] >= 0 || this->setArray[i] >= 0) {
            unionSet.insert(this->setArray[i]);
            unionSet.insert(bSet.setArray[i]);
        }
    }
    return unionSet;
}
Exemplo n.º 7
0
/**
 Operator overload for =. It will assign the inserted array to the given array
 @param bSet the target array that you want to have the content copied.
 @retun original array with the new content being same as bSet.
 */
SortSetArray SortSetArray::operator=(const SortSetArray& bSet) {
    for (int i=0; i < bSet.getSize(); i++) {
        this->setArray[i] = bSet.setArray[i];
    }
    return *this;
}