OOP术语:“容器” & “收集” [英] OOP Terminology: "Container" & "Collection"

查看:158
本文介绍了OOP术语:“容器” & “收集”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C ++术语Container是否与Java术语Collection完全相同?


b C ++术语容器更强调包含项目的所有权,而不是Java的集合,因为没有明确的内存所有权(由于垃圾回收)。



当容器被销毁(因此项目被包含或拥有)时,C ++容器中的项目会被销毁,如果一个集合本身是垃圾,Java项目可能会继续存在


Is the C++ term "Container" simply synonymous with the Java term "Collection" ?

解决方案

Yes.

Though, if I may speculate here, C++ term container better emphasizes ownership of contained items, as opposed to Java's collection, where there is no explicit memory ownership (due to garbage collection).

Items in a C++ container are destroyed when a container is destroyed (hence items are contained or owned), in Java items may continue to exist if a collection itself is garbage collected.

这篇关于OOP术语:“容器” & “收集”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆