* prefer HashSet and HashMap to respective std-classes where possible
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40518 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2011, Oliver Tappe <[email protected]>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PACKAGE__PRIVATE__HASHABLE_STRING_H_
|
||||
#define _PACKAGE__PRIVATE__HASHABLE_STRING_H_
|
||||
|
||||
|
||||
#include <String.h>
|
||||
|
||||
#include <HashString.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
class HashableString : public BString {
|
||||
public:
|
||||
inline HashableString();
|
||||
|
||||
inline HashableString(const BString& string);
|
||||
|
||||
inline uint32 GetHashCode() const;
|
||||
|
||||
inline bool operator!= (const HashableString& other) const;
|
||||
|
||||
private:
|
||||
uint32 fHashCode;
|
||||
};
|
||||
|
||||
|
||||
inline
|
||||
HashableString::HashableString()
|
||||
:
|
||||
fHashCode(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
HashableString::HashableString(const BString& string)
|
||||
:
|
||||
BString(string),
|
||||
fHashCode(string_hash(String()))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline uint32
|
||||
HashableString::GetHashCode() const
|
||||
{
|
||||
return fHashCode;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
HashableString::operator!= (const HashableString& other) const
|
||||
{
|
||||
return Compare(other) != 0 || fHashCode != other.fHashCode;
|
||||
}
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
} // namespace BPackageKit
|
||||
|
||||
|
||||
#endif // _PACKAGE__PRIVATE__HASHABLE_STRING_H_
|
||||
Reference in New Issue
Block a user