游标的复制构造函数?

发布于 2024-11-26 02:50:24 字数 217 浏览 3 评论 0原文

我正在尝试创建一个临时游标,它可以迭代我的数据集,同时将数据成员游标保留在适当的位置,但是当我移动临时游标时,它也会移动主游标,因为看起来临时游标是作为对主游标的引用创建的。有什么办法解决这个问题吗?

Cursor tempCurs = this.cursor;
tempCurs.moveToNext() // This also moves this.cursor

I am trying to create a temporary cursor that can iterate over my data set while leaving the data member cursor in place but when I move my temporary cursor it also moves the primary cursor because it appears the temp is created as a reference to the primary cursor. Is there any way around this?

Cursor tempCurs = this.cursor;
tempCurs.moveToNext() // This also moves this.cursor

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡看悲欢离合 2024-12-03 02:50:24

Cursor 是一个接口,因此为其创建复制构造函数可能很困难。听起来你真正想做的就是记住你在哪里,所以你可以考虑在其周围保留一个 int 变量,而不是使用副本 当前位置 然后恢复 上一个位置

Cursor is a interface so making a copy constructor of it may be difficult. It sounds like all you really want to do is rememeber where you were so instead of using a copy you may consider keeping an int variable around of its current position then restoring the previous position.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文