コード例 #1
0
ファイル: Cluster.cpp プロジェクト: feghalim/ucd-csci2312-pa3
 const Point& Cluster::operator[](unsigned int u) const {
     if(__size == 0) {
         throw EmptyClusterEx();
     }
     if(u >= __size) {
         throw OutOfBoundsEx(u, __size);
     }
     LNodePtr cursor = __points;
     for(int i = 0; i < u; i++) {
         cursor = cursor->next;
     }
     return cursor->point;
 }
コード例 #2
0
ファイル: Cluster.cpp プロジェクト: Gaveno/ucd-csci2312-pa3
    // Operators
    // Members: Sub-script
    const Point &Cluster::operator[](unsigned int index) const {
        if (__size == 0)
            throw EmptyClusterEx();

        if (index >= __size)
            throw OutOfBoundsEx(__size, index);

        LNodePtr cursor = __points;

        for (int i = 0; i < index; ++i) {
            cursor = cursor->next;
        }
        return cursor->point;
    }
コード例 #3
0
    const Point &Cluster::operator[](unsigned int index) const{
        LNodePtr temp;
        temp = __points;
        if(getSize() == 0){
            throw EmptyClusterEx();
        }
        if(index > getSize()-1){
            throw OutOfBoundsEx(getSize()-1,index);
        }

        if(index == 0){
            return __points->point;
        }

        for(int i = 0; i < index; ++i){
            temp = temp->next;
        }
        return temp->point;
    }