/*
* 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: RefHash2KeysTableOf.c 679340 2008-07-24 10:28:29Z borisk $
*/
// ---------------------------------------------------------------------------
// Include
// ---------------------------------------------------------------------------
#if defined(XERCES_TMPLSINC)
#include <xercesc/util/RefHash2KeysTableOf.hpp>
#endif
#include <xercesc/util/Janitor.hpp>
#include <xercesc/util/NullPointerException.hpp>
#include <assert.h>
#include <new>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// RefHash2KeysTableOf: Constructors and Destructor
// ---------------------------------------------------------------------------
template <class TVal, class THasher>
RefHash2KeysTableOf<TVal, THasher>::RefHash2KeysTableOf(
const XMLSize_t modulus,
MemoryManager* const manager)
: fMemoryManager(manager)
, fAdoptedElems(true)
, fBucketList(0)
, fHashModulus(modulus)
, fCount(0)
{
initialize(modulus);
}
template <class TVal, class THasher>
RefHash2KeysTableOf<TVal, THasher>::RefHash2KeysTableOf(
const XMLSize_t modulus,
const THasher& hasher,
MemoryManager* const manager)
: fMemoryManager(manager)
, fAdoptedElems(true)
, fBucketList(0)
, fHashModulus(modulus)
, fCount(0)
, fHasher (hasher)
{
initialize(modulus);
}
template <class TVal, class THasher>
RefHash2KeysTableOf<TVal, THasher>::RefHash2KeysTableOf(
const XMLSize_t modulus,
const bool adoptElems,
MemoryManager* const manager)
: fMemoryManager(manager)
, fAdoptedElems(adoptElems)
, fBucketList(0)
, fHashModulus(modulus)
, fCount(0)
{
initialize(modulus);
}
template <class TVal, class THasher>
RefHash2KeysTableOf<TVal, THasher>::RefHash2KeysTableOf(
const XMLSize_t modulus,
const bool adoptElems,
const THasher& hasher,
MemoryManager* const manager)
: fMemoryManager(manager)
, fAdoptedElems(adoptElems)
, fBucketList(0)
, fHashModulus(modulus)
, fCount(0)
, fHasher (hasher)
{
initialize(modulus);
}
template <class TVal, class THasher>
void RefHash2KeysTableOf<TVal, THasher>::initialize(const XMLSize_t modulus)
{
if (modulus == 0)
ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::HshTbl_ZeroModulus, fMemoryManager);
// Allocate the bucket list and zero them
fBucketList = (RefHash2KeysTableBucketElem<TVal>**) fMemoryManager->allocate
(
fHashModulus * sizeof(RefHash2KeysTableBucketElem<TVal>*)
); //new RefHash2KeysTableBucketElem<TVal>*[fHashModulus];
memset(fBucketList, 0, sizeof(fBucketList[0]) * fHashModulus);
}
template <class TVal, class THasher>
RefHash2KeysTableOf<TVal, THasher>::~RefHash2KeysTableOf()
{
removeAll();
// Then delete the bucket list & hasher
fMemoryManager->deallocate(fBucketList); //delete [] fBucketList;
fBucketList = 0;
}
// ---------------------------------------------------------------------------
// RefHash2KeysTableOf: Element management
// ---------------------------------------------------------------------------
template <class TVal, class THasher>
bool RefHash2KeysTableOf<TVal, THasher>::isEmpty() const
{
return (fCount==0);
}
template <class TVal, class THasher>
bool RefHash2KeysTableOf<TVal, THasher>::
containsKey(const void* const key1, const int key2) const
{
XMLSize_t hashVal;
const RefHash2KeysTableBucketElem<TVal>* findIt = findBucketElem(key1, key2, hashVal);
return (findIt != 0);
}
template <class TVal, class THasher>
void RefHash2KeysTableOf<TVal, THasher>::
removeKey(const void* const key1, const int key2)
{
// Hash the key
XMLSize_t hashVal = fHasher.getHashVal(key1, fHashModulus);
assert(hashVal < fHashModulus);
//
// Search the given bucket for this key. Keep up with the previous
// element so we can patch around it.
//
RefHash2KeysTableBucketElem<TVal>* curElem = fBucketList[hashVal];
RefHash2KeysTableBucketElem<TVal>* lastElem = 0;
while (curElem)
{
if((key2==curElem->fKey2) && (fHasher.equals(key1, curElem->fKey1)))
{
if (!lastElem)
{
// It was the first in the bucket
fBucketList[hashVal] = curElem->fNext;
}
else
{
// Patch around the current element
lastElem->fNext = curElem->fNext;
}
// If we adopted the elements, then delete the data
if (fAdoptedElems)
delete curElem->fData;
// Delete the current element
// delete curElem;
// destructor is empty...
// curElem->~RefHash2KeysTableBucketElem();
fMemoryManager->deallocate(curElem);
fCount--;
return;
}
// Move both pointers upwards
lastElem = curElem;
curElem = curElem->fNext;
}
// We never found that key
ThrowXMLwithMemMgr(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists, fMemoryManager);
}
template <class TVal, class THasher>
void RefHash2KeysTableOf<TVal, THasher>::
removeKey(const void* const key1)
{
// Hash the key
XMLSize_t hashVal = fHasher.getHashVal(key1, fHashModulus);
assert(hashVal < fHashModulus);
//
// Search the given bucket for this key. Keep up with the previous
// element so we can patch around it.
//
RefHash2KeysTableBucketElem<TVal>* curElem = fBucketList[hashVal];
RefHash2KeysTableBucketElem<TVal>* lastElem = 0;
while (curElem)
{
if(fHasher.equals(key1, curElem->fKey1))
{
if (!lastElem)
{
// It was the first in the bucket
fBucketList[hashVal] = curElem->fNext;
}
else
{
// Patch around the current element
lastElem->fNext = curElem->fNext;
}
// If we adopted the elements, then delete the data
if (fAdoptedElems)
delete curElem->fData;
RefHash2KeysTableBucketElem<TVal>* toBeDeleted=curElem;
curElem = curElem->fNext;
// Delete the current element
// delete curElem;
// destructor is empty...
// curElem->~RefHash2KeysTableBucketElem();
fMemoryManager->deallocate(toBeDeleted);
fCount--;
}
else
{
// Move both pointers upwards
lastElem = curElem;
curElem = curElem->fNext;
}
}
}
template <class TVal, class THasher>
void RefHash2KeysTableOf<TVal, THasher>::removeAll()
{
if(isEmpty())
return;
// Clean up the buckets first
for (XMLSize_t buckInd = 0; buckInd < fHashModulus; buckInd++)
{
// Get the bucket list head for this entry
RefHash2KeysTableBucketElem<TVal>* curElem = fBucketList[buckInd];
RefHash2KeysTableBucketElem<TVal>* nextElem;
while (curElem)
{
// Save the next element before we hose this one
nextElem = curElem->fNext;
// If we adopted the data, t
GIS-UE-GDAL-空间数据库-连接查询-代码插件-RTSV2308241700
需积分: 0 111 浏览量
更新于2023-08-26
收藏 72.53MB ZIP 举报
基于GDAL连接多型(包文件型)GIS空间数据库(开源),查询矢量。
可(展望)用于GIS数字孪生App下矢量数据导入成库、局部更新,同时自动生成本地缓存(UEMesh)(详见三方)
详见博文:《UE5下GDAL连接GIS空间库_基本思路_代码插件》
https://blog.csdn.net/siutna/article/details/132516295
WindRippleTrig
- 粉丝: 3
- 资源: 1
最新资源
- Java毕业设计-springboot-vue-校园疫情防控平台(源码+sql脚本+29页零基础部署图文详解+36页论文+21页答辩+环境工具+教程+视频+模板).zip
- 车道线检测MATLAB工程:图像处理与实时视频分析,结合GUI界面与霍夫变换技术,车道线检测matlab工程文件,gui界面,图像处理,图像分割,实时视频检测,霍夫变,具体效果可看主页演示视频,程序包
- 眼疾识别数据集训练集部分
- 基于S函数的永磁同步电机矢量控制双闭环PMSM控制模型在Matlab Simulink中的参数化搭建与实践,采用s函数编写的永磁同步电机矢量控制双闭环PMSM控制模型,利用matlab simulin
- 富兰瓦时(电力电子设备及自动化产品研发商,深圳市富兰瓦时技术有限公司)创投信息
- PMSM高频注入法HFI无传感器位置检测:高频脉振注入的Simulink仿真及公式推导指南,PMSM 高频注入法HFI 无位置传感器 高频脉振注入仿真文件simulink仿真, matlab2018可
- 富瑞氢能(氢能装备提供商,江苏国富氢能技术装备股份有限公司)创投信息
- 歌德盈香(高端酒类推广及拍卖平台,歌德盈香股份有限公司)创投信息
- 风光储互补系统直流微电网Simulink仿真模型:光伏Boost电路与风电永磁直驱整合,混合储能及稳定负载的直流母线电压控制,风光储互补系统直流微电网simulink仿真模型 1.光伏系统通过boo
- 谷雨互动(客户体验管理平台,北京谷雨互动智能科技有限公司)创投信息
- 蓝卓工业互联网(工业操作系统研发商,浙江蓝卓工业互联网信息技术有限公司)创投信息
- 领存集成电路(全自动化芯片检测及芯片封装服务商,广东领存集成电路有限公司)创投信息
- Java毕业设计-springboot-vue-“有光”摄影分享网站(源码+sql脚本+29页零基础部署图文详解+33页论文+环境工具+教程+视频+模板).zip
- Java毕业设计-springboot-vue-爱心商城系统(源码+sql脚本+29页零基础部署图文详解+30页论文+环境工具+教程+视频+模板).zip
- Java毕业设计-springboot-vue-it职业生涯规划系统(源码+sql脚本+29页零基础部署图文详解+33页论文+环境工具+教程+视频+模板).zip
- 斯睿特智能(工业AI智能解决方案研发商,广州市斯睿特智能科技有限公司)创投信息