如何在黑莓应用程序中对持久存储记录进行排序?
您能帮我在 Blackberry 应用程序中对持久存储记录进行排序吗? 我想按升序和降序排序...
Can you please help me in sorting persistent store records in Blackberry application?
I want to sort it in ascending and descending order...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要在黑莓中排序,您可以使用 SimpleSortingVector
但坏消息是,SimpleSortingVector 是不持久的。
因此,要在持久存储中排序,您必须编写
你自己的排序方法。
现在使用任何排序算法对向量的内容进行排序。
For sorting in blackberry you can use SimpleSortingVector
but bad news is, SimpleSortingVector is not persistable.
So for sorting in persistent store you have to write
your own sorting method.
now sort contents of vectors with any sorting algo.
我假设您指的是存储在 PersistableStore 中的排序记录,而不仅仅是实现 Persistable 接口的对象。
为了将数据提交到 PersistentStore:
为了检索向量:
我相信将 SimpleSortingVector 放入 PersistentStore 应该不会有任何问题。但是,它确实混合了数据存储与其行为之间的界限(因为您不仅存储数据记录,还存储比较器和排序信息)。将记录作为 Vector 存储在 PersistentStore 中可能是一个更简洁的解决方案,当您将其从 PersistentStore 中加载时,将其复制到 SimpleSortingVector 中,以便在应用程序的整个运行时使用。如果您采用这种方法,则可以以指定的格式将有关 Comparator 的信息和排序信息存储在 Vector 本身中,并在构造 SimpleSortingVector 时将其提取出来。
I'm assuming you are referring to sorting records which are stored in the PersistentStore, not just objects which implement the Persistable interface.
In order to commit your data to the PersistentStore:
In order to retrieve the vector:
I believe there shouldn't be any issue with putting a SimpleSortingVector in the PersistentStore. However, it does blend the line between the storage of your data and it's behavior (since you are not only storing your data records, but also a Comparator and sorting information). It may be a cleaner solution to store your records in the PersistentStore as just a Vector, and when you load it out of the PersistentStore, copy it into a SimpleSortingVector which you use throughout the runtime of your app. If you went with that approach, you could store information about the Comparator and sorting information in the Vector itself in a specified format, and extract that out when you construct the SimpleSortingVector.