Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:21

0001 /*
0002  * Copyright (c) 2019 Opticks Team. All Rights Reserved.
0003  *
0004  * This file is part of Opticks
0005  * (see https://bitbucket.org/simoncblyth/opticks).
0006  *
0007  * Licensed under the Apache License, Version 2.0 (the "License"); 
0008  * you may not use this file except in compliance with the License.  
0009  * You may obtain a copy of the License at
0010  *
0011  *   http://www.apache.org/licenses/LICENSE-2.0
0012  *
0013  * Unless required by applicable law or agreed to in writing, software 
0014  * distributed under the License is distributed on an "AS IS" BASIS, 
0015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0016  * See the License for the specific language governing permissions and 
0017  * limitations under the License.
0018  */
0019 
0020 // TEST=SSetTest om-t
0021 
0022 #include <cassert>
0023 #include <map>
0024 #include <set>
0025 
0026 #include "OPTICKS_LOG.hh"
0027 
0028 void test_set()
0029 {
0030     std::set<unsigned> a ; 
0031 
0032     a.insert(1) ; 
0033     a.insert(2) ; 
0034     a.insert(2) ; 
0035     a.insert(3) ; 
0036 
0037     assert( a.size() == 3 ); 
0038 }
0039 
0040 
0041 void dump( const std::map<unsigned, std::set<unsigned> >& ms, unsigned i )
0042 {
0043     typedef std::set<unsigned> SU ; 
0044     const SU& s = ms.at(i) ; 
0045     std::cout 
0046           << " s.size() " << s.size() 
0047           << " ( " 
0048           ; 
0049 
0050     for(SU::const_iterator it=s.begin() ; it != s.end() ; it++ ) 
0051           std::cout << *it << " " ; 
0052  
0053     std::cout 
0054           << " ) " 
0055           << std::endl 
0056           ;
0057 
0058 } 
0059 
0060 void test_mapset()
0061 {
0062     std::map<unsigned, std::set<unsigned> > a ; 
0063 
0064     a[0].insert(1) ; 
0065     a[0].insert(2) ; 
0066     a[0].insert(2) ; 
0067     a[0].insert(3) ; 
0068 
0069     dump(a, 0); 
0070 
0071     a[1].insert(1) ; 
0072     a[1].insert(2) ; 
0073     a[1].insert(2) ; 
0074     a[1].insert(3) ; 
0075 
0076     dump(a, 1); 
0077 
0078     assert( a[0].size() == 3 ); 
0079     assert( a[1].size() == 3 ); 
0080 
0081 }
0082 
0083 
0084 
0085 
0086 
0087 int main(int argc, char** argv)
0088 {
0089     OPTICKS_LOG(argc, argv);
0090 
0091     test_set(); 
0092     test_mapset();  
0093 
0094    
0095     return 0 ; 
0096 
0097 }
0098