/* -*- mode: C++; indent-tabs-mode: nil; -*-
* This file is a part of LEMON, a generic C++ optimization library.
* Copyright (C) 2003-2009
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
* (Egervary Research Group on Combinatorial Optimization, EGRES).
* Permission to use, modify and distribute this software is granted
* provided that this copyright notice appears in all copies. For
* precise terms see the accompanying LICENSE file.
* This software is provided "AS IS" with no warranty of any kind,
* express or implied, and with no claim as to its suitability for any
#include <lemon/counter.h>
void bubbleSort(std::vector<T>& v) {
Counter op("Bubble Sort - Operations: ");
Counter::NoSubCounter as(op, "Assignments: ");
Counter::NoSubCounter co(op, "Comparisons: ");
for (int i = v.size()-1; i > 0; --i) {
for (int j = 0; j < i; ++j) {
void insertionSort(std::vector<T>& v) {
Counter op("Insertion Sort - Operations: ");
Counter::NoSubCounter as(op, "Assignments: ");
Counter::NoSubCounter co(op, "Comparisons: ");
for (int i = 1; i < int(v.size()); ++i) {
while (j > 0 && v[j-1] > value) {
template <typename MyCounter>
MyCounter c("Main Counter: ");
typename MyCounter::SubCounter d(c, "SubCounter: ");
typename MyCounter::SubCounter::NoSubCounter e(d, "SubSubCounter: ");
void init(std::vector<int>& v) {
v[0] = 10; v[1] = 60; v[2] = 20; v[3] = 90; v[4] = 100;
v[5] = 80; v[6] = 40; v[7] = 30; v[8] = 50; v[9] = 70;
counterTest<NoCounter>();
init(x); insertionSort(x);