test/counter_test.cc
author deba
Tue, 31 Jan 2006 19:33:48 +0000
changeset 1931 6abf67b02ff5
parent 1847 7cbc12e42482
child 1956 a055123339d5
permissions -rw-r--r--
New iterable map with comparable values
it uses linked lists and balanced binary tree

IterableBoolMap has ItemIt type as the other iterable maps

InvertableMap got ValueIterator
     1 /* -*- C++ -*-
     2  * test/counter_test.cc - Part of LEMON, a generic C++ optimization library
     3  *
     4  * Copyright (C) 2006 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     5  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     6  *
     7  * Permission to use, modify and distribute this software is granted
     8  * provided that this copyright notice appears in all copies. For
     9  * precise terms see the accompanying LICENSE file.
    10  *
    11  * This software is provided "AS IS" with no warranty of any kind,
    12  * express or implied, and with no claim as to its suitability for any
    13  * purpose.
    14  *
    15  */
    16 
    17 #include <lemon/counter.h>
    18 
    19 ///\file \brief Test cases for time_measure.h
    20 ///
    21 ///\todo To be extended
    22 
    23 
    24 int fibonacci(int f) 
    25 {
    26   static lemon::Counter count("Fibonacci steps: ");
    27   count++;
    28   if(f<1) return 0;
    29   else if(f==1) return 1;
    30   else return fibonacci(f-1)+fibonacci(f-2);
    31 }
    32 
    33 int main()
    34 {
    35   fibonacci(10);
    36   
    37   {  
    38     typedef lemon::Counter MyCounter;
    39     MyCounter c("Main counter: ");
    40     c++;
    41     c++;
    42     MyCounter::SubCounter d(c,"Subcounter: ");
    43     d++;
    44     d++;
    45     MyCounter::SubCounter::SubCounter e(d,"SubSubCounter: ");
    46     e++;
    47     e++;
    48   }
    49   
    50   {
    51     typedef lemon::NoCounter MyCounter;
    52     MyCounter c("Main counter: ");
    53     c++;
    54     c++;
    55     MyCounter::SubCounter d(c,"Subcounter: ");
    56     d++;
    57     d++;
    58     MyCounter::SubCounter::SubCounter e(d,"SubSubCounter: ");
    59     e++;
    60     e++;
    61   }
    62 
    63   return 0;
    64 }