Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

提交迭代器及数组的实现 #256

Closed
wants to merge 1 commit into from
Closed

Conversation

junwense
Copy link

创建了一个初步的实现,
迭代器这种工具由于是遍历,所以删除指支持到了删除当前元素。
然后接口设计的error,我觉得hasNext的方法如果返回error,用起来很麻烦,所以加了一个Err(),但是感觉很冗余
对于是否支持在迭代的时候修改元素,本质上还是一个冲突问题。
迭代器本质上关心的还是把元素给取出来遍历,如果需要在迭代器里面对原数据结构修改,我觉得应该是要对不同的数据结构进类型单独设计迭代器方法,而不是放到顶层接口中,如果在迭代的时候如果对原来的数据结构进行了修改,会导致数据不一致问题,结果很难预知,调用者也很难处理。我觉得这个时候应该需要终止迭代器,然后重新获取数组元素。

@junwense
Copy link
Author

fix #118

@flycash
Copy link
Contributor

flycash commented May 17, 2024

感谢,不过目前来看,这方面还要进一步考虑。我先关了这些。

@flycash flycash closed this May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants