![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
00001 /* 00002 Copyright 2005-2010 Intel Corporation. All Rights Reserved. 00003 00004 This file is part of Threading Building Blocks. 00005 00006 Threading Building Blocks is free software; you can redistribute it 00007 and/or modify it under the terms of the GNU General Public License 00008 version 2 as published by the Free Software Foundation. 00009 00010 Threading Building Blocks is distributed in the hope that it will be 00011 useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00012 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with Threading Building Blocks; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 00019 As a special exception, you may use this file as part of a free software 00020 library without restriction. Specifically, if other files instantiate 00021 templates or use macros or inline functions from this file, or you compile 00022 this file and link it with other files to produce an executable, this 00023 file does not by itself cause the resulting executable to be covered by 00024 the GNU General Public License. This exception does not however 00025 invalidate any other reasons why the executable file might be covered by 00026 the GNU General Public License. 00027 */ 00028 00029 #ifndef __TBB_blocked_range2d_H 00030 #define __TBB_blocked_range2d_H 00031 00032 #include "tbb_stddef.h" 00033 #include "blocked_range.h" 00034 00035 namespace tbb { 00036 00038 00039 template<typename RowValue, typename ColValue=RowValue> 00040 class blocked_range2d { 00041 public: 00043 typedef blocked_range<RowValue> row_range_type; 00044 typedef blocked_range<ColValue> col_range_type; 00045 00046 private: 00047 row_range_type my_rows; 00048 col_range_type my_cols; 00049 00050 public: 00051 00052 blocked_range2d( RowValue row_begin, RowValue row_end, typename row_range_type::size_type row_grainsize, 00053 ColValue col_begin, ColValue col_end, typename col_range_type::size_type col_grainsize ) : 00054 my_rows(row_begin,row_end,row_grainsize), 00055 my_cols(col_begin,col_end,col_grainsize) 00056 { 00057 } 00058 00059 blocked_range2d( RowValue row_begin, RowValue row_end, 00060 ColValue col_begin, ColValue col_end ) : 00061 my_rows(row_begin,row_end), 00062 my_cols(col_begin,col_end) 00063 { 00064 } 00065 00067 bool empty() const { 00068 // Yes, it is a logical OR here, not AND. 00069 return my_rows.empty() || my_cols.empty(); 00070 } 00071 00073 bool is_divisible() const { 00074 return my_rows.is_divisible() || my_cols.is_divisible(); 00075 } 00076 00077 blocked_range2d( blocked_range2d& r, split ) : 00078 my_rows(r.my_rows), 00079 my_cols(r.my_cols) 00080 { 00081 if( my_rows.size()*double(my_cols.grainsize()) < my_cols.size()*double(my_rows.grainsize()) ) { 00082 my_cols.my_begin = col_range_type::do_split(r.my_cols); 00083 } else { 00084 my_rows.my_begin = row_range_type::do_split(r.my_rows); 00085 } 00086 } 00087 00089 const row_range_type& rows() const {return my_rows;} 00090 00092 const col_range_type& cols() const {return my_cols;} 00093 }; 00094 00095 } // namespace tbb 00096 00097 #endif /* __TBB_blocked_range2d_H */
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.