问题
· 六月 21, 2021

数据结构+排序算法

除了objectscript 自带的 list,array 数据结构以外,是否有存在其它已经实现好的数据结构,类似 java 里面 collection包一样,是否有已经实现好的排序工具,有没有针对集合类的sort工具。

产品版本: Caché 2012.1
讨论 (6)2
登录或注册以继续

我们之前将数据传入新的索引,以利用objectscript数组的自动排序特性,根据我们希望组织数据的方式,使用基于数字或字母的索引。

例如:s NewData(Data(Key, "Name")) = Data(Key)

对于对象类或映射的globals,我们最近倾向于使用sql查询来对数据进行排序。

还有json和动态数组,可以用于集合/数组数据的存储。

We've previously passed the data into new indices to utilise the auto sorting nature of the objectscript arrays, using a number based or alphabetical index depending on how we're hoping to organise the data.

eg. s NewData(Data(Key,"Name")) = Data(Key)

With object classes or mapped globals we tend to use the sql queries to sort the data as required lately. 

There are the json and dynamic arrays that can be used for collection / array data storage.

It gives you a greater degree of control compared to some languages. I'm not aware that many other languages have a sort thats particularly more sophisticated in reality its probably doing the same just 'under the covers' as theyre higher level than objectscript. The alternative is to pass the data out to whatever front end you're using and have it sort prior to displaying but then most likely its the client doing that work rather than your server. 

与某些语言相比,它给你更大程度的控制。我不知道许多其他语言是否有一个特别复杂的排序,实际上它可能只是在 "掩盖 "做同样的事情,因为它们在objectscript更上面一层。另一种方法是将数据传递给你使用的任何前端,让它在显示之前进行排序,但这样做很可能是由客户端做这项工作,而不是由你的服务器做。