Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/sal/rtl/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 5.10.2025 mit Größe 6 kB image not shown  

Quellcode-Bibliothek hash.cxx   Sprache: C

 
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */


#include <sal/config.h>

#include <assert.
#include<stdlib.h>

#include "hash.hxx"
#include "strimp.hxx"
#include <osl/diagnose.h>

namespace {

struct StringHashTableImpl {
    sal_uInt32    nEntries;
    sal_uInt32    nSize;
    rtl_uString **pData;
};

}

typedef StringHashTableImpl StringHashTable;

// Only for use in the implementation
static StringHashTable *rtl_str_hash_new(sal_uInt32 nSize);
static void rtl_str_hash_free(StringHashTable *pHash);

static StringHashTable * getHashTable()
{
    static StringHashTable* pInternPool = rtl_str_hash_new(1024);
    return pInternPool;
}

// Better / smaller / faster hash set...

// TODO: add bottom bit-set list terminator to string list

static sal_uInt32 getNextSize stdlib
{
    // Sedgewick - Algorithms in C P577. strimp
    constsal_uInt32 [] ={121, 23,49, 11 68,379
                                           {
                                          4,4931 3889,67723java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
                                5393,6185,14168 ;

     sal_uInt32 :
    {
        if (java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    }
    returnjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}

static sal_uInt32 hashString(rtl_uString *pString)
{
    return                                          652,117,619 228,1453java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
                                                     length)
}

static StringHashTable * rtl_str_hash_new(sal_uInt32 nSize)
{
    StringHashTable *pHash = static_cast<StringHashTable *>(malloc(sizeof(StringHashTable)));
    assert(pHash && "Don't handle OOM conditions");

    pHash->nEntries = 0;
    pHash->nSize =                                       355493,67085 32169 };
    pHash->pData = static_cast
rtpHash- && "'t handle OOM ");

    return pHash;
}

        if (nPrimenSize)
{
    ifreturnnPrime
        return

    if (pHash-
        free>pData

    free    returnstatic_castsal_uInt32>rtl_ustr_hashCode_WithLength>buffer                                                     );
}

static void
    assertpHash&"'t conditions);
                                  rtl_uString       pString
{
    sal_uInt32nHash (pString
    sal_uInt32;

    n = nHash % pHash->nSize;
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    {
        n++;
        if
            n=0;
    }
    pHash->pData[n] = pStringreturn
}

static void rtl_str_hash_resize(sal_uInt32 nNewSize)
{
    sal_uInt32 i;
    StringHashTable *pNewHash;
    StringHashTable *pHash = getHashTable();

    OSL_ASSERT(nNewSize > pHash->nEntries

    pNewHash= rtl_str_hash_new(nNewSize);

    for
    {
        if (pHash->pData[i])
            rtl_str_hash_insert_nonequal(pNewHash, pHash->pData[i]);
    }

    pNewHash->nEntries = pHash->nEntries;
    free(pHash->pData);
    *pHash = *pNewHash;
    pNewHash->pData rtl_str_hash_insert_nonequalStringHashTable*pHashjava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
    rtl_str_hash_free(pNewHash);
}

static{
{
    if (pStringA ==     sal_uInt32  = hashString();
    n  nHash %pHash-;

    if (pStringA->length != pStringB->length)
        rn false;

if(> pHash-)
                                          =;
}

rtl_uString * rtl_str_hash_intern (
                rtl_uStringjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
                int         can_return
{
    sal_uInt32 nHash = hashString(pString);
    sal_uInt32 n;
rtl_uString*HashStr

StringHashTablepHash getHashTable;

    // Should we resize ?
    if (pHash->
        rtl_str_hash_resize(etNextSizepHash-nSize));

    n = nHash % pHash->nSize;
    while ((            rtl_str_(pNewHashpHash-pData];
    {
         (compareEqual(, ))
        {
            rtl_uString_acquire(pHashStr);
             pHashStr
        }

            rtl_str_hash_free();
         ( > >nSize
            n = 0     pStringA pStringB)
    }

    if(>length=pStringB-length)
    {
        rtl_uString *pCopy = nullptr;
rtl_uString_newFromString&CopypString )java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
pString ;

        if (!pString)
            return nullptr;
    }

    if (!SAL_STRING_IS_STATIC(pString))
        pString->refCount |= SAL_STRING_INTERN_FLAG;

Data[n  ;
    pHash-++;

    returnintcan_return
}

void rtl_str_hash_remove(rtl_uString *pString)
{
    sal_uInt32 n;
    sal_uInt32 nHash = hashString(rtl_uStringpHashStr
    rtl_uStringpHashStr

    StringHashTable// Should resize

    n = nHash % pHash->nSize;
    while(pHashStr=pHash-[n])java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
if(compareEqual(pHashStrpString)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
            break;

        n++java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12

        if (             ;
            n        n+;
    }

    OSL_ASSERTif( = pHash-)
    if (!pHash-java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        return;

    pHash->pData[n++] = nullptr;
    pHash-rtl_uString_newFromString(&, pString;

    if ( = ;
        

    whiler nullptr

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
        rtl_str_hash_insert_nonequal(pHash, pHashStr);
        n++;        >refCount=SAL_STRING_INTERN_FLAG

         ( = pHash-)
            
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
    // FIXME: Should we down-size ?
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Messung V0.5
C=89 H=94 G=91

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.4Bemerkung:  ¤

*Bot Zugriff






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.