• Home
  • Raw
  • Download

Lines Matching +full:- +full:- +full:root

1 //===--- ImmutableMap.h - Immutable (functional) map interface --*- C++ -*-===//
8 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
21 /// ImutKeyValueInfo -Traits class used by ImmutableMap. While both the first
71 TreeTy* Root;
74 /// Constructs a map from a pointer to a tree root. In general one
78 explicit ImmutableMap(const TreeTy* R) : Root(const_cast<TreeTy*>(R)) { in ImmutableMap()
79 if (Root) { Root->retain(); } in ImmutableMap()
82 ImmutableMap(const ImmutableMap &X) : Root(X.Root) { in ImmutableMap()
83 if (Root) { Root->retain(); } in ImmutableMap()
87 if (Root != X.Root) {
88 if (X.Root) { X.Root->retain(); }
89 if (Root) { Root->release(); }
90 Root = X.Root;
96 if (Root) { Root->release(); } in ~ImmutableMap()
112 TreeTy *T = F.add(Old.Root, std::pair<key_type,data_type>(K,D)); in add()
117 TreeTy *T = F.remove(Old.Root,K); in remove()
131 return Root ? Root->contains(K) : false; in contains()
135 return Root && RHS.Root ? Root->isEqual(*RHS.Root) : Root == RHS.Root;
139 return Root && RHS.Root ? Root->isNotEqual(*RHS.Root) : Root != RHS.Root;
143 if (Root) { Root->retain(); } in getRoot()
144 return Root; in getRoot()
147 TreeTy *getRootWithoutRetain() const { return Root; } in getRootWithoutRetain()
150 if (Root) Root->retain(); in manualRetain()
154 if (Root) Root->release(); in manualRelease()
157 bool isEmpty() const { return !Root; } in isEmpty()
159 //===--------------------------------------------------===//
160 // Foreach - A limited form of map iteration.
161 //===--------------------------------------------------===//
181 if (Root) { in foreach()
183 Root->foreach(CB); in foreach()
189 if (Root) { in foreach()
191 Root->foreach(CB); in foreach()
195 //===--------------------------------------------------===//
197 //===--------------------------------------------------===//
199 void verify() const { if (Root) Root->verify(); } in verify()
201 //===--------------------------------------------------===//
203 //===--------------------------------------------------===//
211 key_type_ref getKey() const { return (*this)->first; } in getKey()
212 data_type_ref getData() const { return (*this)->second; } in getData()
215 iterator begin() const { return iterator(Root); } in begin()
219 if (Root) { in lookup()
220 TreeTy* T = Root->find(K); in lookup()
221 if (T) return &T->getValue().second; in lookup()
227 /// getMaxElement - Returns the <key,value> pair in the ImmutableMap for
231 return Root ? &(Root->getMaxElement()->getValue()) : nullptr; in getMaxElement()
234 //===--------------------------------------------------===//
236 //===--------------------------------------------------===//
238 unsigned getHeight() const { return Root ? Root->getHeight() : 0; } in getHeight()
241 ID.AddPointer(M.Root); in Profile()
264 TreeTy *Root;
268 /// Constructs a map from a pointer to a tree root. In general one
273 : Root(const_cast<TreeTy *>(R)), Factory(F) { in ImmutableMapRef()
274 if (Root) { in ImmutableMapRef()
275 Root->retain(); in ImmutableMapRef()
281 : Root(X.getRootWithoutRetain()), in ImmutableMapRef()
283 if (Root) { Root->retain(); } in ImmutableMapRef()
286 ImmutableMapRef(const ImmutableMapRef &X) : Root(X.Root), Factory(X.Factory) { in ImmutableMapRef()
287 if (Root) { in ImmutableMapRef()
288 Root->retain(); in ImmutableMapRef()
293 if (Root != X.Root) {
294 if (X.Root)
295 X.Root->retain();
297 if (Root)
298 Root->release();
300 Root = X.Root;
307 if (Root) in ~ImmutableMapRef()
308 Root->release(); in ~ImmutableMapRef()
316 if (Root) Root->retain(); in manualRetain()
320 if (Root) Root->release(); in manualRelease()
324 TreeTy *NewT = Factory->add(Root, std::pair<key_type, data_type>(K, D)); in add()
329 TreeTy *NewT = Factory->remove(Root, K); in remove()
334 return Root ? Root->contains(K) : false; in contains()
338 return ImmutableMap<KeyT, ValT>(Factory->getCanonicalTree(Root)); in asImmutableMap()
342 return Root && RHS.Root ? Root->isEqual(*RHS.Root) : Root == RHS.Root;
346 return Root && RHS.Root ? Root->isNotEqual(*RHS.Root) : Root != RHS.Root;
349 bool isEmpty() const { return !Root; } in isEmpty()
351 //===--------------------------------------------------===//
353 //===--------------------------------------------------===//
356 if (Root) in verify()
357 Root->verify(); in verify()
360 //===--------------------------------------------------===//
362 //===--------------------------------------------------===//
370 key_type_ref getKey() const { return (*this)->first; } in getKey()
371 data_type_ref getData() const { return (*this)->second; } in getData()
374 iterator begin() const { return iterator(Root); } in begin()
378 if (Root) { in lookup()
379 TreeTy* T = Root->find(K); in lookup()
380 if (T) return &T->getValue().second; in lookup()
386 /// getMaxElement - Returns the <key,value> pair in the ImmutableMap for
390 return Root ? &(Root->getMaxElement()->getValue()) : 0; in getMaxElement()
393 //===--------------------------------------------------===//
395 //===--------------------------------------------------===//
397 unsigned getHeight() const { return Root ? Root->getHeight() : 0; } in getHeight()
400 ID.AddPointer(M.Root); in Profile()