Added GetHashCode() method and == operator.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29571 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2009-03-17 18:30:33 +00:00
parent 96e1ce6604
commit fabcaf1c0a

View File

@ -155,9 +155,16 @@ struct FSCapabilitiesBase {
inline void Clear(uint32 capability);
inline bool Get(uint32 capability) const;
inline uint32 GetHashCode() const;
inline bool operator==(
const FSCapabilitiesBase<CapabilityCount>&
other) const;
inline void Dump() const;
};
// ClearAll
template<const int CapabilityCount>
inline void
@ -166,6 +173,7 @@ FSCapabilitiesBase<CapabilityCount>::ClearAll()
memset(capabilities, 0, sizeof(capabilities));
}
// Set
template<const int CapabilityCount>
inline void
@ -181,6 +189,7 @@ FSCapabilitiesBase<CapabilityCount>::Set(uint32 capability, bool set)
capabilities[capability / 8] &= ~flag;
}
// Clear
template<const int CapabilityCount>
inline void
@ -189,6 +198,7 @@ FSCapabilitiesBase<CapabilityCount>::Clear(uint32 capability)
Set(capability, false);
}
// Get
template<const int CapabilityCount>
inline bool
@ -201,6 +211,37 @@ FSCapabilitiesBase<CapabilityCount>::Get(uint32 capability) const
return (capabilities[capability / 8] & flag);
}
// GetHashCode
template<const int CapabilityCount>
inline uint32
FSCapabilitiesBase<CapabilityCount>::GetHashCode() const
{
uint32 hashCode = 0;
int byteCount = sizeof(capabilities);
for (int i = 0; i < byteCount; i++)
hashCode = hashCode * 37 + capabilities[i];
return hashCode;
}
// ==
template<const int CapabilityCount>
inline bool
FSCapabilitiesBase<CapabilityCount>::operator==(
const FSCapabilitiesBase<CapabilityCount>& other) const
{
int byteCount = sizeof(capabilities);
for (int i = 0; i < byteCount; i++) {
if (capabilities[i] != other.capabilities[i])
return false;
}
return true;
}
// Dump
template<const int CapabilityCount>
inline void