| 99 | // Main program: |
| 100 | |
| 101 | int main(int argc, char *argv[]) |
| 102 | { |
| 103 | Dictionary<ent>* dictPtr = new Dictionary<ent>; |
| 104 | Dictionary<ent>& dict = *dictPtr; |
| 105 | |
| 106 | for (int i = 0; i<10; i++) |
| 107 | { |
| 108 | ent* ePtr = new ent(word("ent") + name(i), i); |
| 109 | dict.append(ePtr->keyword(), ePtr); |
| 110 | dict.swapUp(ePtr); |
| 111 | } |
| 112 | |
| 113 | Info<< dict << endl; |
| 114 | |
| 115 | dict.swapDown(dict.first()); |
| 116 | |
| 117 | forAllConstIter(Dictionary<ent>, dict, iter) |
| 118 | { |
| 119 | Info<< "element : " << *iter; |
| 120 | } |
| 121 | |
| 122 | Info<< "keys: " << dict.toc() << endl; |
| 123 | |
| 124 | delete dictPtr; |
| 125 | |
| 126 | Dictionary<ent> dict2; |
| 127 | |
| 128 | for (int i = 0; i<10; i++) |
| 129 | { |
| 130 | ent* ePtr = new ent(word("ent") + name(i), i); |
| 131 | dict2.append(ePtr->keyword(), ePtr); |
| 132 | dict2.swapUp(ePtr); |
| 133 | } |
| 134 | |
| 135 | Info<< "dict:\n" << dict2 << endl; |
| 136 | |
| 137 | Info<< nl << "Testing transfer: " << nl << endl; |
| 138 | Info<< "original: " << dict2 << endl; |
| 139 | |
| 140 | Dictionary<ent> newDict; |
| 141 | newDict.transfer(dict2); |
| 142 | |
| 143 | Info<< nl << "source: " << dict2 << nl |
| 144 | << "keys: " << dict2.toc() << nl |
| 145 | << "target: " << newDict << nl |
| 146 | << "keys: " << newDict.toc() << endl; |
| 147 | |
| 148 | |
| 149 | PtrDictionary<Scalar> scalarDict; |
| 150 | for (int i = 0; i<10; i++) |
| 151 | { |
| 152 | word key("ent" + name(i)); |
| 153 | scalarDict.insert(key, new Scalar(1.3*i)); |
| 154 | } |
| 155 | |
| 156 | Info<< nl << "scalarDict1: " << endl; |
| 157 | forAllConstIter(PtrDictionary<Scalar>, scalarDict, iter) |
| 158 | { |