[dasher: 43/217] replaced hash_map with unordered_map



commit 2095564c45f901fe0f5de04f34d3574fd599bb65
Author: ipomoena <amajorek google com>
Date:   Wed Sep 30 22:48:37 2015 -0700

    replaced hash_map with unordered_map

 Src/DasherCore/DasherTypes.h |   13 -------------
 Src/Win32/Widgets/Screen.cpp |    3 +--
 Src/Win32/Widgets/Screen.h   |    8 ++++----
 Src/Win32/Widgets/Screen.inl |   28 +++-------------------------
 4 files changed, 8 insertions(+), 44 deletions(-)
---
diff --git a/Src/DasherCore/DasherTypes.h b/Src/DasherCore/DasherTypes.h
index 93aba72..12cb977 100644
--- a/Src/DasherCore/DasherTypes.h
+++ b/Src/DasherCore/DasherTypes.h
@@ -39,19 +39,6 @@
 #include <string>
 #include <vector>
 
-// Definition for hash_map, platform dependent, not part of STL
-
-// Commented out by pjc - I don't think we use this any more
-// - Okay - maybe we do need this after all
-
-/* #ifdef DASHER_WIN32 */
-/* #include <hash_map> */
-/* #define HASH_MAP stdext::hash_map */
-/* #else */
-/* #include <ext/hash_map> */
-/* #define HASH_MAP __gnu_cxx::hash_map */
-/* #endif */
-
 namespace Dasher {
   // DasherModel co-ordinates are of type myint
   typedef Cint64 myint;
diff --git a/Src/Win32/Widgets/Screen.cpp b/Src/Win32/Widgets/Screen.cpp
index 5031306..4379efe 100644
--- a/Src/Win32/Widgets/Screen.cpp
+++ b/Src/Win32/Widgets/Screen.cpp
@@ -104,7 +104,7 @@ void CScreen::SetColourScheme(const CColourIO::ColourInfo *pColours) {
 void CScreen::SetFont(const string &strFont) {
   if(FontName == strFont) return;
   FontName = strFont;
-  for(stdext::hash_map<int, HFONT>::const_iterator it(m_cFonts.begin()); it != m_cFonts.end(); ++it)
+  for(auto it(m_cFonts.begin()); it != m_cFonts.end(); ++it)
     DeleteObject(it->second);
   m_cFonts.clear();
   for (set<CLabelListScreen::Label*>::iterator it=LabelsBegin(); it!=LabelsEnd(); it++)
@@ -165,7 +165,6 @@ void CScreen::DrawString(CDasherScreen::Label *lab, screenint x1, screenint y1,
 pair<screenint,screenint> CScreen::TextSize(CDasherScreen::Label *lab, unsigned int iSize) {
   Label *label(static_cast<Label *>(lab));
 
-//      stdext::hash_map< CTextSizeInput, CTextSizeOutput, hash_textsize>::const_iterator it;
   map<unsigned int,pair<screenint,screenint> >::const_iterator it = label->m_sizeCache.find(iSize);
   if (it!=label->m_sizeCache.end()) return it->second;
 
diff --git a/Src/Win32/Widgets/Screen.h b/Src/Win32/Widgets/Screen.h
index ae998aa..f9a0673 100644
--- a/Src/Win32/Widgets/Screen.h
+++ b/Src/Win32/Widgets/Screen.h
@@ -19,7 +19,7 @@
 
 #include <vector>
 #include <map>
-#include <hash_map>
+#include <unordered_map>
 
 #ifndef _WIN32_WCE
 #include <cmath>
@@ -113,9 +113,9 @@ private:
   HPEN& GetPen(int iColor, int iWidth);
   HBRUSH& GetBrush(int iColor);
   HFONT& GetFont(int iSize);
-  stdext::hash_map <int, HPEN> m_cPens;  // Holds cached pens
-  stdext::hash_map <int, HBRUSH> m_cBrushes; // Holds cached brushes
-  stdext::hash_map <int, HFONT> m_cFonts;  // Holds cached font sizes for current font
+  std::unordered_map <int, HPEN> m_cPens;  // Holds cached pens
+  std::unordered_map <int, HBRUSH> m_cBrushes; // Holds cached brushes
+  std::unordered_map <int, HFONT> m_cFonts;  // Holds cached font sizes for current font
   std::string FontName; // Shouldn't need to cache, should work on events to reset font cache
 
   class Label : public CLabelListScreen::Label {
diff --git a/Src/Win32/Widgets/Screen.inl b/Src/Win32/Widgets/Screen.inl
index f736ac8..dce01f0 100644
--- a/Src/Win32/Widgets/Screen.inl
+++ b/Src/Win32/Widgets/Screen.inl
@@ -18,8 +18,6 @@ inline void CScreen::DrawRectangle(screenint x1, screenint y1, screenint x2, scr
   if(Colour != -1)
     FillRect(m_hDCBuffer, &Rect, brush);
 
-#ifndef _WIN32_WCE
-
   if(GetWidth() != (screenint)-1) {
 
     point aPoints[5];
@@ -30,11 +28,8 @@ inline void CScreen::DrawRectangle(screenint x1, screenint y1, screenint x2, scr
     aPoints[3].x=x1; aPoints[3].y=y2;
     aPoints[4].x=x1; aPoints[4].y=y1;
 
-       //FrameRect(m_hDCBuffer, &Rect, CScreen::GetBrush(iOutlineColour));
        Polyline(aPoints, 5, iThickness, iOutlineColour==-1 ? 3 : iOutlineColour);
   }
-#endif
-
 }
 
 inline void CScreen::DrawCircle(screenint iCX, screenint iCY, screenint iR, int iFillColour, int 
iLineColour, int iThickness) {
@@ -51,11 +46,9 @@ inline void CScreen::DrawCircle(screenint iCX, screenint iCY, screenint iR, int
     SelectObject(m_hDCBuffer, hBrushOld);
   }
   // TODO: Fix this (?) - looks to take no account of iThickness...and allegedly doesn't work on winCE 
either!
-#ifndef _WIN32_WCE
   if (iThickness>0)
     Arc(m_hDCBuffer, iCX - iR, iCY - iR, iCX + iR, iCY + iR,
                      iCX, iCY - iR, iCX, iCY - iR );
-#endif
 
   SelectObject(m_hDCBuffer, hpOld);
 }
@@ -70,10 +63,6 @@ inline void CScreen::Polyline(point *Points, int Number, int iWidth, int iColour
   SelectObject(m_hDCBuffer, hpOld);
 }
 
-/*inline void CScreen::Polyline(point *Points, int Number, int iWidth) {
-  Polyline(Points, Number, iWidth, 0);
-}*/
-
 inline void CScreen::Blank() {
   RECT rect;
   rect.top = 0;
@@ -101,10 +90,9 @@ inline const void CScreen::point2POINT(const point *In, POINT *Out, int Number)
 }
 
 inline HPEN& CScreen::GetPen(int iColor, int iWidth) {
-  stdext::hash_map <int, HPEN> :: const_iterator hm1_RcIter;
   int key = iColor+iWidth*256;
 
-  hm1_RcIter = m_cPens.find( key );
+  auto hm1_RcIter = m_cPens.find( key );
   if( hm1_RcIter == m_cPens.end() ) {
     HPEN pen = ::CreatePen(PS_SOLID, iWidth, RGB(m_pColours->Reds[iColor], m_pColours->Greens[iColor], 
m_pColours->Blues[iColor]));
     m_cPens[key] = pen;
@@ -114,7 +102,6 @@ inline HPEN& CScreen::GetPen(int iColor, int iWidth) {
 }
 
 inline HBRUSH& CScreen::GetBrush(int iColor) {
-  stdext::hash_map <int, HBRUSH> :: const_iterator hm1_RcIter;
   int key = iColor;
   // TODO: fix this hack. Why is iColor sometimes negative (-1)?
   if(key<0)
@@ -126,7 +113,7 @@ inline HBRUSH& CScreen::GetBrush(int iColor) {
   }
   ////////////////////////////////////////////////////////
 
-  hm1_RcIter = m_cBrushes.find( key );
+  auto hm1_RcIter = m_cBrushes.find( key );
   if( hm1_RcIter == m_cBrushes.end() ) {
     HBRUSH brush = CreateSolidBrush(RGB(m_pColours->Reds[iColor], m_pColours->Greens[iColor], 
m_pColours->Blues[iColor]));
     m_cBrushes[key] = brush;
@@ -136,24 +123,15 @@ inline HBRUSH& CScreen::GetBrush(int iColor) {
 }
 
 inline HFONT& CScreen::GetFont(int iSize) {
-  // TODO: Reimplement
-  //if(FontName != m_pDasherInterface->GetStringParameter(SP_DASHER_FONT)) {
-  //  FontName = m_pDasherInterface->GetStringParameter(SP_DASHER_FONT);
-  //   for(stdext::hash_map<int, HFONT>::const_iterator it(m_cFonts.begin()); it != m_cFonts.end(); ++it)
-  //          DeleteObject(it->second);
-  //  m_cFonts.clear();
-  //}
-
   if (iSize > 50) // ???? Is there a limit to size, should it be a setting?
     iSize = 50;
 
-  stdext::hash_map <int, HFONT> :: const_iterator hm1_RcIter;
   int key = iSize;
 
   std::wstring wstrOutput;
   WinUTF8::UTF8string_to_wstring(FontName, wstrOutput);
 
-  hm1_RcIter = m_cFonts.find( key );
+  auto hm1_RcIter = m_cFonts.find( key );
   if( hm1_RcIter == m_cFonts.end() ) {
     HFONT font = CreateFont(int (-iSize), 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, 
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, LPCWSTR(wstrOutput.c_str())); // 
DEFAULT_CHARSET => font made just from Size and FontName
     m_cFonts[key] = font;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]