首页 \ 问答 \ vector >与c ++中的vector *>相对应(vector> vs. vector*> in c++)

vector >与c ++中的vector *>相对应(vector> vs. vector*> in c++)

显然它会根据你使用的编译器而有所不同,但我很好奇在执行vector<vector<largeObject>>vector<vector<largeObject>*>时的性能问题,特别是在c ++中。 具体来说:

假设您已将外部矢量填满,并且您希望开始将元素插入第一个内部矢量。 如果外部向量只是存储指针,那将如何存储在内存中,就像存储整个内部向量一样。 是否必须移动整个外部向量以获得更多空间,或者移动内部向量(假设空间未预先分配),从而导致外部向量出现问题?

谢谢


Obviously it will vary depending on the compiler you use, but I'm curious as to the performance issues when doing vector<vector<largeObject>> vs. vector<vector<largeObject>*>, especially in c++. In specific:

let's say that you have the outer vector full, and you want to start inserting elements into first inner vector. How will that be stored in memory if the outer vector is just storing pointers, as apposed to storing the whole inner vector. Will the whole outer vector have to be moved to gain more space, or will the inner vector be moved (assuming that space wasn't pre-allocated), causing problems with the outer vector?

Thank you


原文:https://stackoverflow.com/questions/4719796
更新时间:2023-05-09 12:05

最满意答案

如您所述,您的PHP URL可能指向localhost 。 在iOS中,localhost指的是手机本身。 因此,它将无法找到您的PHP应用程序。

这些只是猜测,因此分享一些代码来澄清问题非常重要。 同时,这里有一些要考虑的问题。

  1. 确保您的服务器PHP应用程序可通过IP或主机名访问。(最好是IP)。
  2. 确保您的iPhone作为PHP应用程序的主机连接到LAN。
  3. 更改PHP API的URL以使用API​​主机的IP而不是localhost

As you mentioned, your PHP URL may be pointing to localhost. From the iOS, the localhost is referring to the phone itself. So, it won't be able to find your PHP app.

These are just speculations, so it is very important to share some code to clarify the problem. Meanwhile, here are some points to consider.

  1. Make sure that your server PHP app is accessible by IP or hostname.(preferably IP).
  2. Make sure that your iPhone is connected to the LAN as the host of the PHP app.
  3. Change the URL of the PHP API to use the IP of the API host not localhost.

相关问答

更多
  • 如何恢复IOS[2022-05-08]

    如果tftp上面有备份的话直接在特权模式输入:copy tftp running IP+name就行了!
  • 什么是ios?[2023-01-24]

    Iphone的一种操作系统
  • 什么是ios[2023-04-10]

    Operating System,简称OS,操作系统的意思! iOS的最初名字是iPhone OS,顾名思义就是iPhone的OS(操作系统)
  • 一、IOS是由苹果公司开发的手持设备操作系统。iPhone Operating System 的缩写,不是单词,所以直接读字母就行。 二、iOS是由苹果公司开发的移动操作系统 。苹果公司最早于2007年1月9日的Macworld大会上公布这个系统,最初是设计给iPhone使用的,后来陆续套用到iPod touch、iPad以及Apple TV等产品上。iOS与苹果的Mac OS X操作系统一样,属于类Unix的商业操作系统。原本这个系统名为iPhone OS,因为iPad,iPhone,iPod touch ...
  • 您需要在info.plist文件中设置相应的标志,方法与要求跟踪用户位置或访问照片库和相机的方法相同。 默认情况下,苹果会阻止请求不安全的网络电话,即http。 您可以查看如何设置个别异常或将NSAllowsArbitraryLoads设置为true以允许ALL不安全的调用。 当然,这被认为是更简单但不太安全的选择。 Running network calls under a test case, needs the framework of XCTestExpectation. Test case doe ...
  • XCode 4.6无论如何都不支持iOS 7。 您将只能构建将在iOS 7上运行的iOS 6应用程序,但您将无法使用新的iOS 7 SDS功能。 如果您想支持iOS 7功能,则需要使用Xcode 5.这可能还会在您的应用中引起一些视觉问题。 我的建议是迁移到Xcode 5,然后检查你的应用程序中的所有内容是否正常,或者进行必要的更改以便在iOS 7上正常运行。 在任何情况下,如果您发现任何事情都无法按预期运行,您可以安全地从Xcode 5返回到Xcode 4。 XCode 4.6 will not supp ...
  • 在JS文件中你可以使用以下(当你需要快速决定每个平台代码使用什么时更好) /*at top file*/ var platform = require("platform"); var nativePlatformLocalhost; /*in some function or globally*/ if(platform.device.os === platform.platformNames.ios){ /*localhost for ios*/ nativePlatformLocalhost ...
  • 这可以在localhost上完成。 但是你对端口有一些误解。 端口 - 要建立与服务器的连接,您需要其IP地址和端口号。 端口号是IP协议确定将哪个数据包发送到哪个应用程序的方式。 因此使用随机端口将不起作用。 使用GCDAsycSocket连接到localhost 创建GCDAsycSocket的新实例 调用- (BOOL)connectToHost:(NSString *)host onPort:(uint16_t)port error:(NSError **)errPtr; 使用host参数作为@"l ...
  • 是的,你仍然可以使用你目前使用的书。 其中大部分将保持不变。 UI元素可能看起来有点不同。 将弃用一些API(注意编译器警告,表明如此)。 您还可以使用一些新的API。 您可以在Apple的发行说明中查看iOS 7中的新功能。 Yes you can still use the book you are currently using. Most of it will remain the same. The UI elements might look a tad different. There wil ...
  • 如您所述,您的PHP URL可能指向localhost 。 在iOS中,localhost指的是手机本身。 因此,它将无法找到您的PHP应用程序。 这些只是猜测,因此分享一些代码来澄清问题非常重要。 同时,这里有一些要考虑的问题。 确保您的服务器PHP应用程序可通过IP或主机名访问。(最好是IP)。 确保您的iPhone作为PHP应用程序的主机连接到LAN。 更改PHP API的URL以使用API主机的IP而不是localhost 。 As you mentioned, your PHP URL may b ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。