本文整理汇总了C++中DArray类的典型用法代码示例。如果您正苦于以下问题:C++ DArray类的具体用法?C++ DArray怎么用?C++ DArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: alloc
static DArray<T> alloc(Memory& mem, size_t length)
{
auto ptr = cast(T*)mem.allocRaw(ARRAY_BYTE_SIZE(length) MEMBERTYPEID);
DArray<T> ret = {ptr, length};
ret.zeroFill();
return ret;
}
示例2:
DArray<uint16> * LocalNodeInfo::getSubscribingClients (Message *pMsg)
{
DArray<uint16> *pSubscribingClients = NULL;
uint16 j = 0;
_m.lock (314);
for (UInt32Hashtable<SubscriptionList>::Iterator i = _localSubscriptions.getAllElements(); !i.end(); i.nextElement()) {
PtrLList<Subscription> *pSubscriptions = i.getValue()->getSubscriptionWild (pMsg->getMessageHeader()->getGroupName());
// Get every subscribed group that matches with the message's group
if (pSubscriptions != NULL) {
for (Subscription *pSub = pSubscriptions->getFirst(); pSub != NULL; pSub = pSubscriptions->getNext()) {
if ((pSub->getSubscriptionType() == Subscription::GROUP_PREDICATE_SUBSCRIPTION) || pSub->matches(pMsg)) {
if (pSubscribingClients == NULL) {
pSubscribingClients = new DArray<uint16>();
}
bool bFound = false;
for (unsigned int k = 0; k < pSubscribingClients->size(); k++) {
if ((*pSubscribingClients)[k] == i.getKey()) {
bFound = true;
break;
}
}
if (!bFound) {
(*pSubscribingClients)[j] = i.getKey();
j++;
}
}
}
delete pSubscriptions;
pSubscriptions = NULL;
}
}
_m.unlock (314);
return pSubscribingClients;
}
示例3: tidSearchRecord
DArray<JournalRecord*> * Journal::getJournalRecords(uint64_t start_tid, uint64_t end_tid){
DArray<JournalRecord*> *recs = new DArray<JournalRecord*>();
int idx = -1;
#if TID_HASHTABLE == 1
while((idx = tidSearchRecord(start_tid)) == -1) // psakse se pio index tou Journal tha ksekinisw na psaxnw
start_tid += 1; // an den yparxei to tid pou mou dwse san start psakse to epomeno
#else
while((idx = searchRecord(start_tid)) == -1) // psakse se pio index tou Journal tha ksekinisw na psaxnw
start_tid += 1; // an den yparxei to tid pou mou dwse san start psakse to epomeno
#endif
int rsize = Records->size();
for (int i = idx; i < rsize; i++){ // psakse siriaka apo ekei pou sou gurise i binary search
// mexri to end_tid
uint64_t tid = (Records->get(i))->getTransactionId(); // tid of the specific JournalRecord
if (tid <= end_tid) { // oso den exw kseperasei to end_tid
recs->push_back(Records->get(i));
}
else
break;
}
return recs;
}
示例4: dup
DArray<T> dup(Memory& mem)
{
auto retPtr = cast(T*)mem.allocRaw(ARRAY_BYTE_SIZE(length) MEMBERTYPEID);
DArray<T> ret = {retPtr, this->length};
ret.slicea(*this);
return ret;
}
示例5: UplinkAssert
void PrintBTree ( BTree <char *> *btree )
{
UplinkAssert ( btree );
DArray <char *> *uo = btree->ConvertToDArray ();
DArray <char *> *uo_id = btree->ConvertIndexToDArray ();
for ( int i = 0; i < uo->Size (); ++i ) {
if ( uo->ValidIndex (i) ) {
UplinkAssert ( uo_id->ValidIndex (i) );
printf ( "Index = %s\n", uo_id->GetData (i) );
if ( uo->GetData (i) )
printf ( "%s\n", uo->GetData (i) );
else
printf ( "NULL\n" );
}
}
delete uo;
delete uo_id;
}
示例6: sample
/*
* Evaluate pressure, and add to accumulator.
*/
void McStressAutoCorrelation::sample(long iStep)
{
double pressure;
double temperature;
McSystem& sys=system();
sys.computeStress(pressure);
DArray<double> elements;
elements.allocate(9);
Tensor total;
if (isAtInterval(iStep)){
sys.computeVirialStress(total);
temperature = sys.energyEnsemble().temperature();
elements[0] = (total(0,0) - pressure / 3.0) / (10.0 * temperature);
elements[1] = (total(0,1) + total(1,0)) / 2.0 / (10.0 * temperature);
elements[2] = (total(0,2) + total(2,0)) / 2.0 / (10.0 * temperature);
elements[3] = elements[1];
elements[4] = (total(1,1) - pressure / 3.0) / (10.0 * temperature);
elements[5] = (total(1,2) + total(2,1)) / 2.0 / (10.0 * temperature);
elements[6] = elements[2];
elements[7] = elements[5];
elements[8] = (total(2,2) - pressure / 3.0) / (10.0 * temperature);
accumulator_.sample(elements);
}
}
示例7: hashFunction
//=======================================================================================================
DArray<uint64_t>* Key_HashTable::getHashRecords(unsigned key)
{
unsigned hashed_key;
hashed_key = hashFunction(key);
int index = getBucketIndex(hashed_key, globalDepth); // koitaw ta globaldepth deksia bits gia na dw se poio index tha paw
Bucket* tempBucket = bucketArray.get(index);
DArray<uint64_t>* array = new DArray<uint64_t>();
if((tempBucket->empty == false) && (tempBucket->key == key)){
BucketData* tempData = tempBucket->first;
do
{
array->push_back(tempData->offsets[0]);
if(tempData-> second_of == true)
array->push_back(tempData->offsets[1]);
tempData = tempData->next;
}while(tempData != NULL);
if(array->size() == 0)
{
delete array;
return NULL;
}
return array;
}
else
// cout << "getHashRecords: Key not found" << endl;
if(array->size() == 0)
{
delete array;
return NULL;
}
return array;
}
示例8: Size
DArray <char *> *BTree<T>::ConvertIndexToDArray()
{
DArray <char *> *darray = new DArray <char *>;
darray->SetSize( Size() );
RecursiveConvertIndexToDArray( darray, this );
return darray;
}
示例9: InitArray
void EigenVectors::InitArray(DArray &darr, int size) const {
if(!darr.empty()) {
darr.clear();
}
darr.reserve(size);
for(int i = 0; i < size; ++i) {
darr.push_back(0.);
}
}
示例10:
void EclSuperUnHighlightAll ()
{
DArray <char *> *highlights = superhighlightedbuttons.ConvertIndexToDArray ();
for ( int i = 0; i < highlights->Size (); ++i )
if ( highlights->ValidIndex (i) )
EclSuperUnHighlight ( highlights->GetData (i) );
}
示例11: main
int main() {
DArray<char> myArray;
char theChar = 'a';
for(int i = 0; i < 26; i++){
myArray.add(theChar);
theChar++;
cout << myArray.getArray()[i] << endl;
}
}
示例12: checkAndLogMsg
int TopologyWorldState::printWorldStateInfo (void)
{
// Prints information about local node, like subscriptions, alive neighbors, dead peers, etc
_m.lock (141);
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "=========================================================================\n");
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " PRINT WORLD STATE INFO\n");
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " Node id: %s\n", _pDisService->getNodeId());
if ((_pLocalNodeInfo->getConsolidatedSubscriptions())->getCount() == 0) {
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " No subscribed groups\n");
} else {
_pLocalNodeInfo->printAllSubscribedGroups();
// Print subscribing clients
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " SUBSCRIBING CLIENTS:\n");
DArray<uint16> *pSubClients = _pLocalNodeInfo->getAllSubscribingClients();
for (int j = 0; j <= pSubClients->getHighestIndex(); j++) {
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " SUB CLIENT N.%d:\n", (*pSubClients)[j]);
SubscriptionList *pSubsForClient = _pLocalNodeInfo->getSubscriptionListForClient ((*pSubClients)[j]);
_pLocalNodeInfo->releaseLocalNodeInfo();
if (pSubsForClient && pSubsForClient->getCount() != 0) {
for (StringHashtable<Subscription>::Iterator i = pSubsForClient->getIterator(); !i.end(); i.nextElement()) {
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " SUBSCRIPTION:\n");
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " groupname %s\n", i.getKey());
Subscription *pS = i.getValue();
pS->printInfo();
}
}
}
// Print local consolidated subscriptions
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " LOCAL CONSOLIDATED SUBSCRIPTIONS:\n");
SubscriptionList *pSubscriptions = _pLocalNodeInfo->getConsolidatedSubscriptions();
for (StringHashtable<Subscription>::Iterator i = pSubscriptions->getIterator(); !i.end(); i.nextElement()) {
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " SUBSCRIPTION:\n");
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " groupname %s\n", i.getKey());
Subscription *pS = i.getValue();
pS->printInfo();
}
}
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "-------------------------------------------------------------------------\n");
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " %d ACTIVE NEIGHBORS\n", _pLocalNodeInfo->getCount());
for (StringHashtable<Thing>::Iterator iNeighbors = _pLocalNodeInfo->getAllElements(); !iNeighbors.end(); iNeighbors.nextElement()) {
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "-------------------------------------------------------------------------\n");
RemoteNodeInfo *pRNI = (RemoteNodeInfo *) iNeighbors.getValue();
pRNI->printRemoteNodeInfo();
}
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "-------------------------------------------------------------------------\n");
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, " %d DEAD PEERS\n", _deadPeers.getCount());
for (StringHashtable<RemoteNodeInfo>::Iterator iDead = _deadPeers.getAllElements(); !iDead.end(); iDead.nextElement()) {
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "-------------------------------------------------------------------------\n");
RemoteNodeInfo *pRNI = (RemoteNodeInfo *) iDead.getValue();
pRNI->printRemoteNodeInfo();
}
checkAndLogMsg ("TopologyWorldState::printWorldStateInfo", Logger::L_Info, "=========================================================================\n");
_m.unlock (141);
return 0;
}
示例13: addAddFiltersToConsolidateList
void LocalNodeInfo::addAddFiltersToConsolidateList (const char *pszGroupName)
{
_m.lock (328);
// Get all the client subscribing the group
DArray<uint16> *pSubClients = NULL;//getSubscribingClients (pszGroupName);
Subscription *pSCons = _consolidatedSubscriptions.getSubscription (pszGroupName);
if ((pSubClients == NULL) || (!((pSCons != NULL) && (pSCons->getSubscriptionType() == Subscription::GROUP_SUBSCRIPTION)))) {
_m.unlock (328);
return;
}
GroupSubscription *pGSCons = (GroupSubscription *) pSCons;
// Look for the first subscribing client which subscribes by a GROUP_SUBSCRIPTION
uint16 ui16ClientId;
Subscription *pS = NULL;
for (int i = 0; i <= pSubClients->getHighestIndex(); i++) {
ui16ClientId = (*pSubClients)[i];
SubscriptionList *pSL = NULL;
if (((pSL = _localSubscriptions.get(ui16ClientId)) != NULL) && ((pS = pSL->getSubscription(pszGroupName)) != NULL)) {
if (pS->getSubscriptionType() == Subscription::GROUP_SUBSCRIPTION) {
break;
}
if (pS->getSubscriptionType() == Subscription::GROUP_PREDICATE_SUBSCRIPTION) {
// I want every tag - remove them and return
pGSCons->removeAllFilters();
_m.unlock (328);
return;
}
}
}
// match every filter against every other subscribing client's tag list.
// Add it iff:
// 1) Every other GROUP_SUBSCRIPTION has the same filter
// 2) No one of the other GROUP_TAG_SUBSCRIPTION subscribe the tag
// 3) There is not any GROUP_PREDICATE_SUBSCRIPTION for the group
GroupSubscription *pGS = (GroupSubscription*) pS;
DArray<uint16> *pTags = pGS->getAllFilters();
for (int i = 0; i <= pTags->getHighestIndex(); i++) {
bool bAddFilter = true;
int16 ui16Tag = (*pTags)[i];
for (int j = 0; j <= pSubClients->getHighestIndex(); j++) {
Subscription *pS = NULL;
if (pS->matches(ui16Tag)) {
bAddFilter = false;
break;
}
}
if (bAddFilter) {
pGSCons->addFilter((*pTags)[i]);
}
}
_m.unlock (328);
}
示例14: Remove
void InterfaceScreen::Remove ()
{
DArray<char *> *btns = this->interface_buttons;
for ( int i = 0; i < btns->Size(); ++i ) {
if ( btns->ValidIndex( i ) ) {
char *btn_name = btns->GetData( i );
if ( (NULL != btn_name) && ('\0' != btn_name[0]) )
EclRemoveButton( btn_name );
}
}
}
示例15: checkAndLogMsg
int DSProImpl::requestMoreChunks (const char *pszChunkedMsgId, const char *pszCallbackParameter)
{
const char *pszMethodName = "DSProImpl::requestMoreChunks";
if (pszChunkedMsgId == NULL) {
return -1;
}
_m.lock (2010);
if (_userReqs.put (pszChunkedMsgId, pszCallbackParameter) == 0) {
checkAndLogMsg (pszMethodName, Logger::L_MildError, "new chunk requested "
"and added it to _userReqs\n", pszChunkedMsgId);
}
Targets **ppTargets = _pTopology->getNeighborsAsTargets();
if (ppTargets == NULL) {
_m.unlock (2010);
return 0;
}
if (ppTargets[0] == NULL) {
delete ppTargets;
_m.unlock (2010);
return 0;
}
uint8 ui8TotalNumberOfChunks = 0;
DArray<uint8> *pCachedChunkIds = _pDataStore->getCachedChunkIDs (pszChunkedMsgId, ui8TotalNumberOfChunks);
int rc = _adaptMgr.sendChunkRequestMessage (pszChunkedMsgId, pCachedChunkIds,
getNodeId(), ppTargets);
Targets::deallocateTargets (ppTargets);
String chunkIds ("");
if (pCachedChunkIds != NULL) {
for (unsigned int i = 0; i < pCachedChunkIds->size(); i++) {
chunkIds += ((uint32) (*pCachedChunkIds)[i]);
chunkIds += " ";
}
delete pCachedChunkIds;
pCachedChunkIds = NULL;
}
if (rc < 0) {
checkAndLogMsg (pszMethodName, Logger::L_Warning, "could not request more chunks "
"for %s. Return code %d. The already received chunks are: <%s>\n",
pszChunkedMsgId, rc, chunkIds.c_str());
}
else {
checkAndLogMsg (pszMethodName, Logger::L_Info, "requested more chunks for message %s. "
"The already received chunks are: <%s>\n", pszChunkedMsgId, chunkIds.c_str());
}
_m.unlock (2010);
return (rc < 0 ? -2 : 0);
}