【c++STL】和【java集合类】的比较?

一葉孤星坠空城丶 2014-08-03 09:32:07
最好詳細點。。。。。。。。
...全文
924 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ID870177103 2016-12-11
  • 打赏
  • 举报
回复
容器是一种逻辑上的概念,根据实现分成不同的类 1。线性容器(数组,变长数组,循环数组,单链表,双链表,循环链表) 2。集合(树形集合,哈希集合,位集) 3。映射表(将集合的元素分成元素标注key和元素对应数据value) 在容器的基础上衍生其它对象 栈,队列等
jiqiang01234 2016-12-11
  • 打赏
  • 举报
回复
引用 7 楼 chen_shiqiang 的回复:
[quote=引用 6 楼 guzhijie1981 的回复:] LZ是要调用方法呢,还是内部原理的解释? 据我所知,C++模板是在预编译阶段就被实例化,这个实例化是函数或者类的实例,不是对象那种实例,而java的泛型,其实到了也是编译阶段,是为了防止程序员错误代码而引入的机制。 java的泛型有? extends A, ? super A,表示泛型使用具体的类,可以有继承关系,或者是某个类的父类。而c++的模板,更多的是直接代替。因为java本身有线程,和线程安全的问题。使用java有些集合是线程安全的,而c++本身没有这样的要求。 另外,java传递的都是引用,而c++容器存放的是对象的复制品。这个区别还是蛮大的
java传递的都是引用,而c++容器存放的是对象的复制品, 这个坑啊 C++模板是在预编译阶段就被实例化, 不用初始化[/quote] 所以c++11需要move语义来化解对象拷贝
Mrchesian 2016-12-07
  • 打赏
  • 举报
回复
引用 6 楼 guzhijie1981 的回复:
LZ是要调用方法呢,还是内部原理的解释? 据我所知,C++模板是在预编译阶段就被实例化,这个实例化是函数或者类的实例,不是对象那种实例,而java的泛型,其实到了也是编译阶段,是为了防止程序员错误代码而引入的机制。 java的泛型有? extends A, ? super A,表示泛型使用具体的类,可以有继承关系,或者是某个类的父类。而c++的模板,更多的是直接代替。因为java本身有线程,和线程安全的问题。使用java有些集合是线程安全的,而c++本身没有这样的要求。 另外,java传递的都是引用,而c++容器存放的是对象的复制品。这个区别还是蛮大的
java传递的都是引用,而c++容器存放的是对象的复制品, 这个坑啊 C++模板是在预编译阶段就被实例化, 不用初始化
guzhijie1981 2014-08-11
  • 打赏
  • 举报
回复
LZ是要调用方法呢,还是内部原理的解释? 据我所知,C++模板是在预编译阶段就被实例化,这个实例化是函数或者类的实例,不是对象那种实例,而java的泛型,其实到了也是编译阶段,是为了防止程序员错误代码而引入的机制。 java的泛型有? extends A, ? super A,表示泛型使用具体的类,可以有继承关系,或者是某个类的父类。而c++的模板,更多的是直接代替。因为java本身有线程,和线程安全的问题。使用java有些集合是线程安全的,而c++本身没有这样的要求。 另外,java传递的都是引用,而c++容器存放的是对象的复制品。这个区别还是蛮大的
赵4老师 2014-08-03
  • 打赏
  • 举报
回复
jvm指令通常再快也比不过CPU指令。 无profiler不要谈效率!!尤其在这个云计算、虚拟机、模拟器、CUDA、多核 、多级cache、指令流水线、多种存储介质、……满天飞的时代!
lm_whales 2014-08-03
  • 打赏
  • 举报
回复
1)没看懂, 2)java不熟悉,所以不知道如何比较
  • 打赏
  • 举报
回复
同时深入了解java和c++的人不多
Zephyr风暴之锤 2014-08-03
  • 打赏
  • 举报
回复
两者大同小异的。 这是Java的 Collection ├List │├LinkedList │├ArrayList │└Vector │ └Stack └Set Map ├Hashtable ├HashMap └WeakHashMap 这是c++STL的 vector ,deque, list set, multiset, map, multimap 此外还有:栈stack 、队列queue 和优先级priority_queue 三种适配器
Zephyr风暴之锤 2014-08-03
  • 打赏
  • 举报
回复
lz你说的是“容器(collection)"吧?
Book Description Written for the moderately experienced Java programmer, this book builds on readers¿ existing knowledge of object-oriented programming and covers all important aspects of Standard C++—emphasizing more lower-level C-style details later in the presentation. Chapter topics include philosophy of C++, simplest C++, pointers and reference variables, object-based programming: classes, operator overloading, object-oriented programming: inheritance, templates, abnormal control flow, input and output, collections: the standard template library, primitive arrays and strings, C-style C++, and using Java and C++: the JNI. For new C++ programmers converted from Java. For experienced Java programmers and students who require the skills of C++ programming, best-selling author Mark Allen Weiss bridges the gap. He efficiently presents the complex C++ language in this well-designed tutorial/reference that both students and seasoned programmers will appreciate. The book is ideal as a primary text for intermediate C++ courses, as a supplemental no-nonsense reference for other courses, or for independent learning by professionals. C++ for Java Programmers is a concise, well-written text that provides authoritative and up-to-date coverage of key features and details of C++, with a special focus on how C++ compares to Java. The book's approach shows knowledgeable students or professionals how to grasp the complexities of C++ and harness its power by mutually addressing the benefits and the pitfalls of the two languages. By highlighting the features and comparative elements of each language, and building on the reader's existing knowledge of object-oriented programming, C++ for Java Programmers enables users to master the essentials of C++ quickly and thoroughly. Key Features Includes insightful comparisons of the two programming languages throughout the text and points out the subtleties of C++ Succinctly covers the pertinent highlights of STL (Standard Template Library) and the most effective use of templates Explains the use of the powerful JNI (Java Native Interface) for combining Java and C++ Includes a summary of key C++ features and issues with each chapter Provides extensive treatment of C details the programmer is likely to encounter in C++ Companion Website for complete online source code at: http://www.prenhall.com/weiss Available Instructors Resource CD-ROM Product Details Paperback: 304 pages Publisher: Prentice Hall; 1 edition (November 7, 2003) Language: English ISBN-10: 013919424X ISBN-13: 978-0139194245 Product Dimensions: 9.5 x 6.8 x 0.6 inches

65,210

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧