Пример #1
0
int main(int argc, char **argv) {
  CS225::SparseVector v;
  for (int i=0;i<10;++i) v.Insert(i+1,i);
  const CS225::SparseVector cv(v);
  cv[3]=5;
  return 0;
}
Пример #2
0
void test18() {
    CS225::SparseVector v;
    for (int i=0;i<10;++i) v.Insert(i+1,i);
    const CS225::SparseVector cv(v);
    int i = cv[3] + cv[4];
    std::cout << "cv[3] + cv[4] = " << i << std::endl;
}
Пример #3
0
int main(int argc, char **argv) {
  CS225::SparseVector v;
  for (int i=0;i<10;++i) v.Insert(i+1,i);
  const CS225::SparseVector cv(v);
  CS225::SparseVector v2(cv); // copy from const - OK
  v2 = v + cv;
  v2 = cv + v;
  return 0;
}
Пример #4
0
void test12() {
    CS225::SparseVector v;
    for (int i=0;i<10;++i) v.Insert(i+1,i);

    std::cout << "v = " << v << std::endl;
    v.PrintRaw(); std::cout << std::endl;

    v[1] += v[5];
    std::cout << "v = " << v << std::endl;
    v.PrintRaw(); std::cout << std::endl;

    v[2] -= v[2];
    std::cout << "v = " << v << std::endl;
    v.PrintRaw(); std::cout << std::endl;
}
Пример #5
0
void test11() {
    CS225::SparseVector v;
    for (int i=0;i<10;++i) v.Insert(i+1,i);
    std::cout << "v = " << v << std::endl;

    std::cout << "Second element is v[2]=" << v[2] << std::endl;

    v[2]=5;
    std::cout << "v = " << v << std::endl;
    v.PrintRaw(); std::cout << std::endl;

    int temp=v[5];
    std::cout << "v[5]=" << temp << std::endl;
    v.PrintRaw(); std::cout << std::endl;

    v[6] += -5; v[5] -= 3;
    std::cout << "v = " << v << std::endl;
    v.PrintRaw(); std::cout << std::endl;

    v[2] = v[8];
    std::cout << "v = " << v << std::endl;
    v.PrintRaw(); std::cout << std::endl;
}