00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00036 00037 #ifndef SGI_block_h_INCLUDED 00038 #define SGI_block_h_INCLUDED 00039 00040 #include <iterator> 00041 #include <stddef.h> 00042 00043 namespace SGI { 00044 00045 template <class T, size_t N> 00046 struct block { 00047 typedef T value_type; 00048 00049 typedef value_type* pointer; 00050 typedef const value_type* const_pointer; 00051 typedef value_type& reference; 00052 typedef const value_type& const_reference; 00053 00054 typedef ptrdiff_t difference_type; 00055 typedef size_t size_type; 00056 00057 typedef value_type* iterator; 00058 typedef const value_type* const_iterator; 00059 00060 typedef std::reverse_iterator<iterator> reverse_iterator; 00061 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 00062 00063 iterator begin() { return data; } 00064 iterator end() { return data + N; } 00065 00066 const_iterator begin() const { return data; } 00067 const_iterator end() const { return data + N; } 00068 00069 reverse_iterator rbegin() { return reverse_iterator(end()); } 00070 reverse_iterator rend() { return reverse_iterator(begin()); } 00071 00072 const_reverse_iterator rbegin() const { return reverse_iterator(end()); } 00073 const reverse_iterator rend() const { return reverse_iterator(begin()); } 00074 00075 reference operator[](size_type n) { return data[n]; } 00076 const_reference operator[](size_type n) const { return data[n]; } 00077 00078 size_type size() const { return N; } 00079 bool empty() const { return N == 0; } 00080 size_type max_size() const { return N; } 00081 00082 void swap(block& x); 00083 00084 T data[N]; 00085 }; 00086 00087 template <class T, size_t N> 00088 void block<T, N>::swap(block<T, N>& x) { 00089 for (size_t n = 0; n < N; ++n) 00090 std::swap(data[n], V.data[N]); 00091 } 00092 00093 } // Close namespace SGI 00094 00095 #endif /* SGI_block_h_INCLUDED */
1.5.6