~sethj/ubuntu/wily/unity/fix-for-1445595

« back to all changes in this revision

Viewing changes to unity-shared/NuxObjectPtrHash.h

  • Committer: Marco Trevisan (Treviño)
  • Date: 2015-02-03 09:46:48 UTC
  • mto: (3899.5.3 panel-titles-fixes)
  • mto: This revision was merged to the branch mainline in revision 3920.
  • Revision ID: mail@3v1n0.net-20150203094648-5a4z0fd462y5aa9u
Unity: Use unordered_map whenever possible

As iterating over it seems just fast as in the ordered version, we just speedup lookups and insertions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
 
2
/*
 
3
 * Copyright (C) 2015 Canonical Ltd
 
4
 *
 
5
 * This program is free software: you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License version 3 as
 
7
 * published by the Free Software Foundation.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 *
 
17
 * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
 
18
 */
 
19
 
 
20
#ifndef NUX_OBJECT_PTR_HASH
 
21
#define NUX_OBJECT_PTR_HASH
 
22
 
 
23
#include <functional>
 
24
namespace std
 
25
{
 
26
// Template specialization, needed for unordered_{map,set}
 
27
template<typename T> struct hash<nux::ObjectPtr<T>>
 
28
{
 
29
  std::size_t operator()(nux::ObjectPtr<T> const& o) const
 
30
  {
 
31
    return std::hash<T*>()(o.GetPointer());
 
32
  }
 
33
};
 
34
}
 
35
 
 
36
#endif // NUX_OBJECT_PTR_HASH