ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/SkipList.cpp
Revision: 1097
Committed: Mon Apr 12 20:32:20 2004 UTC (20 years, 2 months ago) by gezelter
File size: 833 byte(s)
Log Message:
Changes for RigidBody dynamics (Somewhat extensive)

File Contents

# User Rev Content
1 gezelter 1097 #include <iostream>
2     #include <stdlib.h>
3    
4     #include "SkipList.hpp"
5    
6     SkipList* SkipList::_instance = 0;
7    
8     SkipList* SkipList::Instance() {
9     if (_instance == 0) {
10     _instance = new SkipList;
11     }
12     return _instance;
13     }
14    
15     SkipList::SkipList(){
16     }
17    
18     SkipList::~SkipList() {
19     delete _instance;
20     }
21    
22     void SkipList::addAtom(int i) {
23    
24     if (!hasAtom(i))
25     skipSet.insert(i);
26    
27     }
28    
29    
30     void SkipList::printMe( void ){
31    
32     set<int>::iterator i;
33     int index;
34    
35     index = 0;
36     for(i = skipSet.begin(); i != skipSet.end(); ++i) {
37    
38     std::cerr << "SkipList[" << index << "] i: " << *i << "\n";
39     index++;
40     }
41     }
42    
43     int SkipList::hasAtom(int i) {
44    
45     set<int>::iterator position;
46    
47     position = skipSet.find(i);
48    
49     if (position != skipSet.end())
50     return 1;
51     else
52     return 0;
53    
54     }
55    
56     int SkipList::getSize() {
57     return skipSet.size();
58     }