BWAPI
|
00001 #pragma once 00002 00003 #include <vector> 00004 00005 template <typename T> 00006 class RectangleArray 00007 { 00008 public: 00009 RectangleArray(unsigned int width, unsigned int height, T val = T()) 00010 : mData(width, std::vector<T>(height, val)) 00011 {} 00012 00013 RectangleArray() 00014 {} 00015 00016 void resize(unsigned int width, unsigned int height, T val = T()) 00017 { 00018 mData.resize(width); 00019 for(unsigned int i = 0; i < width; ++i) 00020 mData[i].resize(height, val); 00021 } 00022 00023 const std::vector<T> &operator[](int i) const 00024 { 00025 return mData[i]; 00026 } 00027 00028 std::vector<T> &operator[](int i) 00029 { 00030 return mData[i]; 00031 } 00032 00033 private: 00034 std::vector<std::vector<T>> mData; 00035 };