如何从数组传递到vector - c ++(How to pass from array to vector - c++)
我是c ++编程的新手,我试图更好地理解数组和向量之间的差异。 在我的程序中,我有一个类Graph,其中一些数组作为私有成员。 该类有一个方法,使用这些数组实现最小生成树的Prim算法。 我从这个页面中取出算法并将其更改为我的程序。
我现在被要求使用向量而不是数组,所以我想知道:
我真的需要改变多少东西? 声明和构造函数,好的。 但循环,初始化。 我必须改变一切吗? 该计划无论如何都有效。 使用向量函数是否如此重要?
I'm new in c++ programming and I'm trying to understand better the differences between array and vector. In my program I've got a class Graph with some arrays as private members. The class has a method that use these arrays to implement the Prim's algorithm for minimum spanning tree. I took the algorithm from this page and changed it for my program.
I am now asked to use vectors instead of arrays so I would like to know:
How many things do I really have to change? The declaration and the constructors, ok. But the cycles, the initializations. Do I have to change everything? The program works anyway. Is it so important to use vector's function?
原文:https://stackoverflow.com/questions/19909185
最满意答案
事实证明,跟踪器名称中的破折号导致它无法正常工作。 切换到跟踪器名称的camelBack外壳修复了问题。 就我所见, 目前的文档中没有关于允许字符的内容 。 看起来只是字母和数字应该是安全的 - 即通过/ ^ [0-9a-zA-Z] + $ / regex。
Turns out, it was the dashes in the tracker name that caused it to not work. Switching to camelBack casing for the tracker name fixed the problem. There is nothing about allowed characters in the current documentation as far as I have seen. It seems just letters and numbers should be used to be safe - i.e. one that passes a /^[0-9a-zA-Z]+$/ regex.
相关问答
更多-
谷歌分析 - 一个页面上的多个跟踪器(cookie冲突)(google analytics - multiple trackers on one page (cookie conflict))[2022-05-18]
现在使用新的异步跟踪代码变得简单。 :) https://developers.google.com/analytics/devguides/collection/gajs/#MultipleCommands Now made easy with the new asynchronous tracking code. :) https://developers.google.com/analytics/devguides/collection/gajs/#MultipleCommands -
在新行字符之前的ga语句中有一个额外的双引号...更不用说你在第一个/最后一个调用中使用了引号。 ga('create', 'UA-XXXXXXXX-Y', 'example.com'); ga('send', 'pageview'); You have an extra double quote ...
-
事实证明,跟踪器名称中的破折号导致它无法正常工作。 切换到跟踪器名称的camelBack外壳修复了问题。 就我所见, 目前的文档中没有关于允许字符的内容 。 看起来只是字母和数字应该是安全的 - 即通过/ ^ [0-9a-zA-Z] + $ / regex。 Turns out, it was the dashes in the tracker name that caused it to not work. Switching to camelBack casing for the tracker nam ...
-
为什么我的网页浏览量依赖Google Analytics与Adwords不相符?(Why my pageviews count on Google Analytics vs Adwords doesn't fit?)[2023-07-30]
简单地说: 点击次数与访问次数不同 。 据谷歌官方解释 : Google AdWords会跟踪点击次数,而Google Analytics会跟踪访问次数。 如果用户在30分钟内点击您的广告两次而未关闭其浏览器,则Google会将此注册为访问您网站的一次,即使该用户离开您的网站后不久又返回。 例如,如果用户点击您的广告一次,点击后退按钮,然后再次点击您的广告,AdWords会在Google注册一次访问时注册两次点击。 但是你的数字很不错。 您是否已查看Google Analytics实施 - 是否正在跟踪所有 ... -
Google Analytics - 统计事件发生前的浏览量(Google Analytics- Count amount of pageviews before event happens)[2022-09-04]
GTM / GA没有内置的支持。 但是,您可以使用GTM自定义HTML标记来部署一个简单的脚本,该脚本将在cookie / sessionStorage的帮助下计算搜索次数,以便随后可以以GTM用户定义的变量 There is no built-in support for this in the GTM/GA. But you can use GTM Custom HTML tag to deploy a simple script that will count the number of search ... -
尝试配置和触发单个跟踪器会绕过使用标记管理器的目的。 相反: dataLayer.push({event:'spa.pageView', page:..., title:...}); 哪里: dataLayer可选地在gtm片段中重命名 spa是您的app / project / company /的一个方便的缩写,以防您以后需要区分其操作。 page和title可以是您喜欢的任何内容,您将通过在GTM容器中添加dataLayer宏来引用它们。 然后,在标记管理器中配置: {{event}} ends w ...
-
我认为这个问题最好在Google Analytics领域内解决,您可以在其中创建一个忽略网址ID部分的特定报告。 这样您就可以最简单地使用Google Analytics,而无需对项目进行任何代码更改 I think this question is best answered by this article. As the other contributors suggested, I too thought the issue should be resolved in Google Analytics ...
-
你不需要,但如果你这样做,它将以任何方式工作。 You don't need to, but if you do it will work either way.
-
您无法在Google Analytics中跟踪用户IP,因为它违反了分析条款和条件。 另一种方法是为每个访问者分配一个用户ID,以跟踪每个用户的更多细节。 谢谢 You can not track user IP in google analytics, as it's against analytics terms & conditions. the other way you can do is by assigning each visitor a user-ID to track more deta ...
-
跟踪器是Google Analytics用于捕获所有跟踪活动的总体对象,无论是自定义指标,维度等。 自定义指标和维度是在跟踪器上设置的对象,可以发送到您的GA帐户。 语法类似于我设想的设置自定义指标,但所有GA跟踪的sytax非常相似,易于开发。 Trackers are the overall objects that Google Analytics uses to capture all tracking activities, be it custom metrics, dimensions etc ...