test/counter_test.cc
author deba
Thu, 27 Dec 2007 13:40:16 +0000
changeset 2547 f393a8162688
parent 1956 a055123339d5
child 2553 bfced05fa852
permissions -rw-r--r--
Renaming state_enum to State
Removing "Type" suffix from typedefs
Moving implementation into the class definition
     1 /* -*- C++ -*-
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library
     4  *
     5  * Copyright (C) 2003-2007
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     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.
    12  *
    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
    15  * purpose.
    16  *
    17  */
    18 
    19 #include <lemon/counter.h>
    20 
    21 ///\file \brief Test cases for time_measure.h
    22 ///
    23 ///\todo To be extended
    24 
    25 
    26 int fibonacci(int f) 
    27 {
    28   static lemon::Counter count("Fibonacci steps: ");
    29   count++;
    30   if(f<1) return 0;
    31   else if(f==1) return 1;
    32   else return fibonacci(f-1)+fibonacci(f-2);
    33 }
    34 
    35 int main()
    36 {
    37   fibonacci(10);
    38   
    39   {  
    40     typedef lemon::Counter MyCounter;
    41     MyCounter c("Main counter: ");
    42     c++;
    43     c++;
    44     MyCounter::SubCounter d(c,"Subcounter: ");
    45     d++;
    46     d++;
    47     MyCounter::SubCounter::SubCounter e(d,"SubSubCounter: ");
    48     e++;
    49     e++;
    50   }
    51   
    52   {
    53     typedef lemon::NoCounter MyCounter;
    54     MyCounter c("Main counter: ");
    55     c++;
    56     c++;
    57     MyCounter::SubCounter d(c,"Subcounter: ");
    58     d++;
    59     d++;
    60     MyCounter::SubCounter::SubCounter e(d,"SubSubCounter: ");
    61     e++;
    62     e++;
    63   }
    64 
    65   return 0;
    66 }