diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2007-09-27 12:51:08 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2007-09-27 12:51:08 +0000 |
commit | 0463c31163ddeb9289863e7ca035b31c62ea0151 (patch) | |
tree | 69a72f01694358a392472c5cf8a5da3e6984b922 /sc/inc/address.hxx | |
parent | b2941c8c41b25c7b2e7053868fbe7a3894ba415e (diff) |
INTEGRATION: CWS calc44 (1.13.96); FILE MERGED
2007/09/07 13:24:38 er 1.13.96.1: #i81336# #b6582756# new ScLookupCache, caching strategy for VLOOKUP and MATCH
Diffstat (limited to 'sc/inc/address.hxx')
-rw-r--r-- | sc/inc/address.hxx | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx index bb62d404b3b8..8f22e5a1bf19 100644 --- a/sc/inc/address.hxx +++ b/sc/inc/address.hxx @@ -4,9 +4,9 @@ * * $RCSfile: address.hxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: obo $ $Date: 2007-06-13 09:04:04 $ + * last change: $Author: hr $ $Date: 2007-09-27 13:51:08 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -327,6 +327,8 @@ public: inline bool operator>( const ScAddress& r ) const; inline bool operator>=( const ScAddress& r ) const; + inline size_t hash() const; + // moved from ScTripel /// "(1,2,3)" String GetText() const; @@ -412,6 +414,20 @@ inline bool ScAddress::operator>=( const ScAddress& r ) const return !operator<( r ); } + +inline size_t ScAddress::hash() const +{ + // Assume that there are not that many addresses with row > 2^16 AND column + // > 2^8 AND sheet > 2^8 so we won't have too many collisions. + if (nRow <= 0xffff) + return (static_cast<size_t>(nTab) << 24) ^ + (static_cast<size_t>(nCol) << 16) ^ static_cast<size_t>(nRow); + else + return (static_cast<size_t>(nTab) << 28) ^ + (static_cast<size_t>(nCol) << 24) ^ static_cast<size_t>(nRow); +} + + // === ScRange =============================================================== class SC_DLLPUBLIC ScRange @@ -467,6 +483,9 @@ public: inline bool operator<=( const ScRange& r ) const; inline bool operator>( const ScRange& r ) const; inline bool operator>=( const ScRange& r ) const; + + inline size_t hash() const; + inline size_t hashStartColumn() const; }; inline void ScRange::GetVars( SCCOL& nCol1, SCROW& nRow1, SCTAB& nTab1, @@ -523,6 +542,36 @@ inline bool ScRange::In( const ScRange& r ) const aStart.Tab() <= r.aStart.Tab() && r.aEnd.Tab() <= aEnd.Tab(); } + +inline size_t ScRange::hash() const +{ + // Assume that there are not that many ranges with identical corners so we + // won't have too many collisions. Also assume that more lower row and + // column numbers are used so that there are not too many conflicts with + // the columns hashed into the values, and that start row and column + // usually don't exceed certain values. High bits are not masked off and + // may overlap with lower bits of other values, e.g. if start column is + // greater than assumed. + return + (static_cast<size_t>(aStart.Row()) << 26) ^ // start row <= 2^6 + (static_cast<size_t>(aStart.Col()) << 21) ^ // start column <= 2^5 + (static_cast<size_t>(aEnd.Col()) << 15) ^ // end column <= 2^6 + static_cast<size_t>(aEnd.Row()); // end row <= 2^15 +} + + +inline size_t ScRange::hashStartColumn() const +{ + // Assume that for the start row more lower row numbers are used so that + // there are not too many conflicts with the column hashed into the higher + // values. + return + (static_cast<size_t>(aStart.Col()) << 24) ^ // start column <= 2^8 + (static_cast<size_t>(aStart.Row()) << 16) ^ // start row <= 2^8 + static_cast<size_t>(aEnd.Row()); +} + + // === ScRangePair =========================================================== class ScRangePair |