remove util::array

std::array or boost::array can be used instead.
This commit is contained in:
gfgtdf 2016-04-27 21:43:37 +02:00
parent c876280a95
commit f4d714d690
2 changed files with 3 additions and 77 deletions

View File

@ -1,74 +0,0 @@
/*
Copyright (C) 2003 - 2016 by David White <dave@whitevine.net>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
/**
* @file
* Template for arrays.
*/
#ifndef ARRAY_HPP_INCLUDED
#define ARRAY_HPP_INCLUDED
#include <algorithm>
namespace util
{
template<typename T,size_t N>
class array
{
public:
typedef T value_type;
typedef T* iterator;
typedef const T* const_iterator;
typedef T& reference;
typedef const T& const_reference;
typedef size_t size_type;
array() {}
array(const T& o)
{
std::fill(begin(),end(),o);
}
iterator begin() { return a; }
iterator end() { return a + N; }
const_iterator begin() const { return a; }
const_iterator end() const { return a + N; }
reference operator[](size_type n) { return a[n]; }
const_reference operator[](size_type n) const { return a[n]; }
reference front() { return a[0]; }
reference back() { return a[N-1]; }
const_reference front() const { return a[0]; }
const_reference back() const { return a[N-1]; }
size_type size() const { return N; }
bool empty() const { return size() == 0; }
T* data() { return a; }
const T* data() const { return a; }
private:
T a[N];
};
} // end namespace util
#endif

View File

@ -37,8 +37,8 @@
#include "attack_prediction.hpp"
#include "actions/attack.hpp"
#include "array.hpp"
#include "game_config.hpp"
#include <array>
#if defined(BENCHMARK) || defined(CHECK)
#include <time.h>
@ -207,11 +207,11 @@ private:
private: // data
const unsigned int rows_, cols_;
util::array<double *, NUM_PLANES> plane_;
std::array<double *, NUM_PLANES> plane_;
// For optimization, we keep track of the rows and columns with data.
// (The matrices are likely going to be rather sparse, with data on a grid.)
util::array<std::set<unsigned>, NUM_PLANES> used_rows_, used_cols_;
std::array<std::set<unsigned>, NUM_PLANES> used_rows_, used_cols_;
};