c ++等价于c ++向量或deque

编程入门 行业动态 更新时间:2024-10-23 15:32:37
本文介绍了c ++等价于c ++向量或deque的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我几乎可以肯定这应该是一个重复,但我搜索了一段时间,无法找到答案。我应该使用在C#中替换C ++向量和deque 有效。这是我需要一个结构,有效地支持直接索引,并支持从一个或两个端点(取决于向量或deque case)再次以一种有效的方式删除。

I am almost certain this should be a duplicate but I searched for some time and could not find the answer. What should I use in C# to replace C++ vector and deque efficiently. That is I need a structure that supports direct indexing effieciently and also supports delete from one or both ends(depending on vector or deque case) again in an efficient manner.

java我通常使用ArrayList至少为向量,但对于C#我发现这个源说: ArrayList动态调整大小。随着元素的添加,它增加容量以容纳它们。它最常用于较旧的C#程序。。那么什么是新的方法呢?

In java I usually use ArrayList at least for vector but for C# I found this source that states: ArrayList resizes dynamically. As elements are added, it grows in capacity to accommodate them. It is most often used in older C# programs.. So what is the new way to do this? And again what do I do for the deque case?

推荐答案

没有内置的Deque容器,但有几个实现可用

There's no built-in Deque container, but there are several implementations available.

这里是一个来自Stephen Cleary的好人。

与Vector相同的C#是 列表< T> 。索引访问是O(1),但是插入或删除是O(N)(除了在末尾插入,这是O(1))。

The C# equivalent to Vector is List<T>. Indexed access is O(1), but insertion or removal is O(N) (other than Inserting at the end, which is O(1)).

更多推荐

c ++等价于c ++向量或deque

本文发布于:2023-11-09 15:42:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572764.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:向量   deque

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!