本文整理汇总了C++中DynamicArray::getSize方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicArray::getSize方法的具体用法?C++ DynamicArray::getSize怎么用?C++ DynamicArray::getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicArray
的用法示例。
在下文中一共展示了DynamicArray::getSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: road
std::vector<Road> Algorithm::findShortestPath(MultiGraph<double, Station>* graph, Station* start, Station* end ,double &lenght)
{
DynamicArray<Station> *stations = graph->getVertexs();
std::vector<Road> result;
if (stations->getIndex(start) != -1 && stations->getIndex(end) != -1)
{
DynamicArray<Station> *vertexs = graph->getVertexs();
int size = vertexs->getSize();
double* arr = new double[size*size];
Graph g;
g.resize(size);
for (int i = 0; i < size; i++)
{
Station*startTemp= vertexs->get(i);
for (int j = 0; j < size; j++)
{
Station*endTemp = vertexs->get(j);
DynamicArray<double>* values = graph->getLenghtsByStation(startTemp, endTemp);
if (values != 0 && values->getSize() > 0)
{
double value = Algorithm::findMin(values);
arr[j*size + i] = value;
g[i].push_back(std::make_pair(j, value));
}
}
}
std::vector<int> path;
int startIndex = vertexs->getIndex(start);
int endIndex = vertexs->getIndex(end);
dijkstra(g, startIndex, endIndex, path);
double sum = 0;
for (int i = path.size() - 1; i >= 0; i--)
{
if (i - 1 >= 0)
{
Station * resultStart = vertexs->get(path[i]);
Station * resultEnd = vertexs->get(path[i - 1]);
Road road(resultStart, resultEnd);
result.push_back(road);
sum += arr[path[i - 1] * size + path[i]];
}
//std::cout << path[i] << "->";
}
//cout << "\n";
//cout << sum;
lenght = sum;
delete[] arr;
}
return result;
}
示例2: runStage
void _FSSEnvironment::runStage(const Operation& subject,
DynamicArray<StyleTreeNode*>& styleTreePositions,
HashMap<StyleTreeNode*, bool, HashCollection::pointerHash<StyleTreeNode>,
HashCollection::pointerMatch<StyleTreeNode>>& styleTreePositionSet,
Allocator& stackAllocator, FDUint depth) {
#ifdef FD_FSS_DIAGNOSTIC_PRINT
const char* depthString = " ";
FDUint depthStringLen = strlen(depthString);
printf("%s%c/%s\n", depthString + depthStringLen - depth,
subject.getName().ownerType, subject.getName().name);
#endif
int positionsListingStart = styleTreePositions.getSize();
StyleTree& tree = styleSheet.getTree();
DynamicArray<StyleTreeNode*> styleTreePositionsToAdd(stackAllocator);
HashMap<PropertyDef*, void*, HashCollection::pointerHash<PropertyDef>,
HashCollection::pointerMatch<PropertyDef>> defToProperty(
stackAllocator);
// Check the style sheet tree for the properties of the subject.
{
Profiler p("FSS check for properties", true);
Profiler pApplicable("Def Applicable Rules", true);
DynamicArray<StyleRule*> applicableRules(stackAllocator);
pApplicable.close();
// Follow up on rules suggested by the subject.
// Note that we do not keep such rules in the listing of styleTreePositions
// - instead we only store multi-atom rules that have a first-atom match.
{
Profiler p("FSS check rules", true);
Array<StyleRule* const> relatedRules = subject.getRelatedRules();
for (int i = 0; i < relatedRules.length; i++) {
applicableRules.append(relatedRules[i]);
Selector& selector = relatedRules[i]->getSelector();
tree.advanceTopRule(*relatedRules[i], subject,
styleTreePositionsToAdd, styleTreePositionSet);
}
}
// Extract properties from the list of rules.
{
Profiler p("FSS extract properties", true);
FDUint ruleCount = applicableRules.getSize();
for (FDUint i = 0; i < ruleCount; i++) {
Array<Style> styles = applicableRules[i]->getStyles();
for (int j = 0; j < styles.length; j++) {
Style& style = styles[j];
StyleDef& styleDef = style.getDef();
PropertyDef& propertyDef = styleDef.getPropertyDef();
// Create the property if it doesn't already exist.
void* prop;
if (!defToProperty.get(&propertyDef, prop)) {
prop = propertyDef.createProperty(stackAllocator);
defToProperty[&propertyDef] = prop;
}
style.invoke(prop);
}
}
}
{
Profiler p("FSS do inline styles.", true);
Array<const Style> inlineStyles = subject.getInlineStyles();
FDUint inlineStyleCount = inlineStyles.length;
for (FDUint i = 0; i < inlineStyleCount; i++) {
const Style& style = inlineStyles[i];
StyleDef& styleDef = style.getDef();
PropertyDef& propertyDef = styleDef.getPropertyDef();
// Create the property if it doesn't already exist.
void* prop;
if (!defToProperty.get(&propertyDef, prop)) {
Profiler pNF("Not found shit", true);
prop = propertyDef.createProperty(stackAllocator);
defToProperty[&propertyDef] = prop;
}
Profiler p("Invoke Style", true);
style.invoke(prop);
}
}
Profiler pC("FSS prop check cleanup.", true);
}
void* hideVS;
FDbool hasHideProp = defToProperty.get(environment.hidePDef, hideVS);
if (!hasHideProp ||
//.........这里部分代码省略.........
示例3: select
void _FSSEnvironment::select(const Selector& atomSelector,
DynamicArray<Operation*>& resultList) {
// Find the criterion with the lowest number of matching operations.
// Exclude the terminator symbol from the selector while searching.
SelectorCriterion* startingCriterion = NULL;
int criteriaCount = atomSelector.getCriteria().length - 1;
for (int i = 0; i < criteriaCount; i++) {
SelectorCriterion& criterion = atomSelector.getCriteria()[i];
if (criterion.getType() == SelectorCriteriaType::SCT_OPERATION) {
startingCriterion = &criterion;
break;
} else if (criterion.getType() == SelectorCriteriaType::SCT_CLASS) {
if (startingCriterion == NULL || startingCriterion->getType() ==
SelectorCriteriaType::SCT_CLASS)
{
if (startingCriterion == NULL ||
criterion.getClass()->getMembers().length <
startingCriterion->getClass()->getMembers().length) {
startingCriterion = &criterion;
}
} else {
throw AssertionFailureException("Comparing against non-class"\
"criterion", __FILE__, __LINE__);
}
} else {
throw AssertionFailureException("Invalid criterion type.",
__FILE__, __LINE__);
}
}
// Add all operations from the starting criterion to the results list
if (startingCriterion->getType() == SCT_OPERATION) {
resultList.append(startingCriterion->getOperation());
} else if (startingCriterion->getType() == SCT_CLASS) {
int memberCount = startingCriterion->getClass()->getMembers().length;
for (int i = 0; i < memberCount; i++) {
resultList.append(startingCriterion->getClass()->getMembers()[i]);
}
}
// Remove stuff that doesn't match.
for (int i = 0; i < criteriaCount; i++) {
SelectorCriterion& criterion = atomSelector.getCriteria()[i];
if (&criterion == startingCriterion) {
continue;
}
int memberCount = resultList.getSize();
for (int j = 0; j < memberCount; j++) {
bool cull = false;
if (criterion.getType() == SCT_OPERATION) {
cull = resultList[i] != criterion.getOperation();
} else if (criterion.getType() == SCT_CLASS) {
cull = !resultList[i]->hasClass(*criterion.getClass());
} else {
throw AssertionFailureException("Invalid criterion type.",
__FILE__, __LINE__);
}
if (cull) {
resultList.removeAt(j);
memberCount--;
j--;
}
}
}
}