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

iterator access denied?why? #145

Closed
NeuralMayu opened this issue Dec 6, 2022 · 3 comments
Closed

iterator access denied?why? #145

NeuralMayu opened this issue Dec 6, 2022 · 3 comments

Comments

@NeuralMayu
Copy link

No description provided.

@ZLY201
Copy link
Member

ZLY201 commented Dec 6, 2022

Could you give me more information?

Or you just want to know why we checked iterator whether valid?

@NeuralMayu
Copy link
Author

import { LinkList } from 'js-sdsl';
const LinkListRef = React.useRef(new LinkList());
const computed = React.useRef(null);
LinkListRef.current.pushBack(key);
computed.current = LinkListRef.current.begin();
console.log(LinkListRef.current.size()); // 1
console.log(LinkListRef.current.begin());
console.log(LinkListRef.current.end());
console.log(LinkListRef.current.begin().equals(LinkListRef.current.end())); // false
and
image

@ZLY201
Copy link
Member

ZLY201 commented Dec 6, 2022

The end iterator is a super end for all container.

For example:

index 0 1 2 3 4 5
value 1 2 3 4 5 Error

The begin will pointer to index 0 and the value is 1.

The end wlill pointer to index 5 and will get a error when run iteraotr.pointer.

Same as rEnd.

Design ideas from C++ STL.

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

No branches or pull requests

2 participants