test/counter_test.cc
author hegyi
Thu, 05 Jan 2006 12:30:09 +0000
changeset 1878 409a31271efd
parent 1847 7cbc12e42482
child 1956 a055123339d5
permissions -rw-r--r--
Several changes. \n If new map is added to mapstorage it emits signal with the name of the new map. This was important, because from now on not only tha mapwin should be updated. \n Furthermore algobox gets a pointer to mapstorage instead of only the mapnames from it. This is important because without it it would be complicated to pass all of the required maps to algobox.
     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 }