Properly detect the Intel C++ compiler (ticket #154).
1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
3 * This file is a part of LEMON, a generic C++ optimization library.
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 #include <lemon/counter.h>
22 using namespace lemon;
25 void bubbleSort(std::vector<T>& v) {
26 Counter op("Bubble Sort - Operations: ");
27 Counter::NoSubCounter as(op, "Assignments: ");
28 Counter::NoSubCounter co(op, "Comparisons: ");
29 for (int i = v.size()-1; i > 0; --i) {
30 for (int j = 0; j < i; ++j) {
43 void insertionSort(std::vector<T>& v) {
44 Counter op("Insertion Sort - Operations: ");
45 Counter::NoSubCounter as(op, "Assignments: ");
46 Counter::NoSubCounter co(op, "Comparisons: ");
47 for (int i = 1; i < int(v.size()); ++i) {
51 while (j > 0 && v[j-1] > value) {
61 template <typename MyCounter>
63 MyCounter c("Main Counter: ");
65 typename MyCounter::SubCounter d(c, "SubCounter: ");
67 typename MyCounter::SubCounter::NoSubCounter e(d, "SubSubCounter: ");
76 void init(std::vector<int>& v) {
77 v[0] = 10; v[1] = 60; v[2] = 20; v[3] = 90; v[4] = 100;
78 v[5] = 80; v[6] = 40; v[7] = 30; v[8] = 50; v[9] = 70;
83 counterTest<Counter>();
84 counterTest<NoCounter>();
86 std::vector<int> x(10);
87 init(x); bubbleSort(x);
88 init(x); insertionSort(x);