⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 array.h

📁 利用C
💻 H
字号:
// Copyright (C) 2003 Johan Jansson.// Licensed under the GNU LGPL Version 2.1.//// Modified by Anders Logg, 2003-2007.//// First added:  2003-09-03// Last changed: 2007-04-24#ifndef __ARRAY_H#define __ARRAY_H#include <iostream>#include <dolfin/common/types.h>#include <vector>namespace dolfin{  /// Array is a container that provides O(1) access time to elements  /// and O(1) memory overhead.    ///  /// It is a wrapper for std::vector, so see the STL manual for further  /// details: http://www.sgi.com/tech/stl/    template <class T>  class Array : public std::vector<T>  {  public:    /// Create empty array    Array() : std::vector<T>() {}        /// Create array of given size    Array(uint n) : std::vector<T>(n) {}    /// Create array containing two elements    Array(const T& t0, const T& t1)    {      push_back(t0);      push_back(t1);    }    /// Create array containing three elements    Array(const T& t0, const T& t1, const T& t2)    {      push_back(t0);      push_back(t1);      push_back(t2);    }    /// Create array containing four elements    Array(const T& t0, const T& t1, const T& t2, const T& t3)    {      push_back(t0);      push_back(t1);      push_back(t2);      push_back(t3);    }    /// Create array containing five elements    Array(const T& t0, const T& t1, const T& t2, const T& t3, const T& t4)    {      push_back(t0);      push_back(t1);      push_back(t2);      push_back(t3);      push_back(t4);    }    /// Copy constructor    Array(const Array<T>& x) : std::vector<T>(x) {}    /// Assign to all elements in the array    const Array& operator=(const T& t)    {      for (uint i = 0; i < std::vector<T>::size(); i++)      (*this)[i] = t;      return *this;    }    /// Destructor    ~Array() {}  };}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -