游标的复制构造函数?
我正在尝试创建一个临时游标,它可以迭代我的数据集,同时将数据成员游标保留在适当的位置,但是当我移动临时游标时,它也会移动主游标,因为看起来临时游标是作为对主游标的引用创建的。有什么办法解决这个问题吗?
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.