BVB Source Codes

CRYENGINE Show OpenList.h Source code

Return Download CRYENGINE: download OpenList.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  File name:   OpenList.h
  5. //  Description: This is a helper class to implement a open list
  6. ////////////////////////////////////////////////////////////////////////////
  7.  
  8. #ifndef OPENLIST_H
  9. #define OPENLIST_H
  10.  
  11. #pragma once
  12.  
  13. template<typename ElementNode, class BestNodePredicate>
  14. class OpenList
  15. {
  16. public:
  17.         typedef std::vector<ElementNode> ElementList;
  18.  
  19.         OpenList(const size_t maxExpectedSize)
  20.         {
  21.                 SetupOpenList(maxExpectedSize);
  22.         }
  23.  
  24.         ILINE void SetupOpenList(const size_t maxExpectedSize)
  25.         {
  26.                 openElements.reserve(maxExpectedSize);
  27.         }
  28.  
  29.         ElementNode PopBestElement()
  30.         {
  31.                 //FUNCTION_PROFILER(gEnv->pSystem, PROFILE_AI);
  32.  
  33.                 CRY_ASSERT_MESSAGE(!openElements.empty(), "PopBestElement has been requested for an empty ElementNode open list.");
  34.                 BestNodePredicate predicate;
  35.                 typename ElementList::iterator bestElementIt = std::min_element(openElements.begin(), openElements.end(), predicate);
  36.                 ElementNode bestElement = *bestElementIt;
  37.                 *bestElementIt = openElements.back();
  38.                 openElements.pop_back();
  39.  
  40.                 return bestElement;
  41.         }
  42.  
  43.         ILINE void Reset()
  44.         {
  45.                 openElements.clear();
  46.         }
  47.  
  48.         ILINE bool IsEmpty() const
  49.         {
  50.                 return openElements.empty();
  51.         }
  52.  
  53.         ILINE void InsertElement(const ElementNode& newElement)
  54.         {
  55.                 //FUNCTION_PROFILER(gEnv->pSystem, PROFILE_AI);
  56.  
  57.                 assert(!stl::find(openElements, newElement));
  58.                 stl::push_back_unique(openElements, newElement);
  59.         }
  60.  
  61. private:
  62.         ElementList openElements;
  63. };
  64.  
  65. #endif // OPENLIST_H
  66.  
downloadOpenList.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top