从 CObArray 到 ArrayList

发布于 2024-12-06 06:21:29 字数 130 浏览 5 评论 0原文

我有一些 C++ 代码片段将对象存储在 CObArray 中。我想使用 ArrayList 在 Java 中重新编码相同的部分来存储相同的对象。整体效率会有差异吗?

那么 ArrayList 是 CObArray 的确切对应类吗?

I have some pieces of C++ code that store objects in CObArray. I want to re-code the same pieces in Java using ArrayList to store the same objects. Will there be any difference in the overall efficiency?

So is ArrayList the exact correspondent class for CObArray?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我的鱼塘能养鲲 2024-12-13 06:21:29

我不知道 CObArray 是什么: CObArray是 MS 的 C++ 实现的一部分。

他们对 CObArray 的描述听起来就像它的行为方式与 ArrayList 类似。也就是说,在实施和性能方面。您应该记住,接口肯定会有所不同。例如,Java 的 ArrayList 没有类似 GetUpperBound()。如果你依赖这样的东西,你肯定可以确保你可以在没有相应方法的情况下生活。

此外,在 Java 中使用 ArrayList 的首选方法是使用泛型(指定编译时集合中存在的类型,而不是运行时执行的强制转换) )。这听起来可能与根据 AJG85 的 CObArray 的工作方式不同。您还必须确保在开始转换为 Java 之前,您了解此类差异及其工作原理。

I didn't know what a CObArray was: CObArray is part of MS's C++ implementations.

They description of a CObArray sounds like it behaves in a similar fashion to an ArrayList. That is, in terms of implementation and performance. You should bare in mind that the interfaces will differ for sure. For example, Java's ArrayList does not have anything like GetUpperBound(). If you depend on something like this, you sure ensure you can live without corresponding methods.

In addition, the preferred way to work with ArrayList's in Java is by the use of Generics (specify the type that will exist in the collection at compile-time as opposed to casts performed at run-time). This sounds like it may differ from how it works with CObArray's according to AJG85. You must also ensure that before you begin your conversion to Java that you are aware of differences like this and how they work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文