如何取消封装未排序的数组结构的获取算法? [英] How would unencapsulate an unsorted array structure’s fetch algorithm?

查看:82
本文介绍了如何取消封装未排序的数组结构的获取算法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//access the node (assumes the node is in the structure)
i=0;
while(targetKey!=data[i].key()){
i++;
}

// return a a copy of the node to the client 
return data[i].deepCopy();





我尝试了什么:



我认为如果不解包这个问题我将不得不公开deepCopy()的方法实现细节,对吗?



What I have tried:

I would think that to unencapsulate this I would have to expose the deepCopy()'s method implementation details, right?

推荐答案

不是你的问题,但你的代码是完全错误的。

当数组结束时发生什么? code> targetKey 不存在?
Not your question, but your code is plain wrong.
What happen at end of array when the targetKey do not exist ?


这篇关于如何取消封装未排序的数组结构的获取算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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