/****************************************************************************
 * This file was derived from the CNCL library by the Pablo research group.
 *
 * The complete CNCL library is available at:
 *       http://www.comnets.rwth-aachen.de/doc/cncl.html
 *
 * The CNCL copyright notice is included here:
 *
 * |_|_|_  |_|_    |_    |_|_|_  |_               C O M M U N I C A T I O N
 *|_       |_  |_  |_  |_        |_                         N E T W O R K S
 *|_       |_  |_  |_  |_        |_                               C L A S S
 * |_|_|_  |_    |_|_    |_|_|_  |_|_|_|_                     L I B R A R Y
 *
 *
 *
 * Copyright (C) 1992-1998   Communication Networks
 *                           Aachen University of Technology
 *                           D-52056 Aachen
 *                           Germany
 *                           Email: cncl-adm@comnets.rwth-aachen.de
 *
 *
 * This library is free  software; you can  redistribute it and/or modify
 * it  under   the terms  of the GNU   Library  General Public License as
 * published by the  Free Software Foundation;  either  version 2 of  the
 * License, or  (at  your option)  any  later  version.  This  library is
 * distributed  in the  hope  that  it  will  be useful,  but WITHOUT ANY
 * WARRANTY;  without even the   implied  warranty of MERCHANTABILITY  or
 * FITNESS FOR A PARTICULAR PURPOSE.   See the GNU Library General Public
 * Library General Public License along with  this library; if not, write
 * to the Free Software Foundation,  675  Mass Ave, Cambridge, MA  02139,
 * USA.
 ****************************************************************************/

// -*- C++ -*-
/*****************************************************************************
 *
 * Class: FlArrayDouble  --- 1 dimensional double array class
 *
 *****************************************************************************/

#ifndef __ArrayDouble_h
#define __ArrayDouble_h


#include <FlArray.h>


/*
 * The class FlArrayDouble
 */


class FlArrayDouble : public FlArray
{
  public:	/***** Public interface **************************************/
    virtual void size(size_t sz=0);	// Set size of array

    void put(int index, double value)	// Put value into array
    {
#   ifndef NO_RANGE_CHECK
	if(index<0 || asize<=(size_t)index)
	    range_error(index);
	else
#   endif
	    array[index] = value;
    }

    double get(int index) const		// Get value from array
    {
#   ifndef NO_RANGE_CHECK
	if (index<0 || asize<=(size_t)index)
	{   range_error(index); return 0; }
	else
#   endif
	    return array[index];
    }

    double& operator[] (int index)	// Operator []
    {
#   ifndef NO_RANGE_CHECK
	if (index<0 || asize<=(size_t)index)
	    range_error(index);
#   endif
	return array[index];
    }

  private:	/***** Internal private members ******************************/
    friend class FlPArrayDouble;
    
    double *array;			// Array of double
    double def_val;			// Default value
    
    void init(size_t sz);		// Initialize array
    void delete_array();                // Delete array

  public:	/***** Constructors ******************************************/
    FlArrayDouble()          : FlArray((size_t)0), array(NIL), def_val(0) {}

    FlArrayDouble(size_t sz, double def=0);
    FlArrayDouble(const FlArrayDouble &a);		// Copy constructor

    ~FlArrayDouble();

    FlArrayDouble &operator = (const FlArrayDouble &a);
    
    // Print/debug output
    virtual void print(ostream &strm = cout) const;
    virtual void dump (ostream &strm = cout) const;
};

#endif /**__ArrayDouble_h**/
