什么是红宝石(1.8.7)模拟SortedDictionary在C#/。NET? [英] What is Ruby (1.8.7) analog to SortedDictionary in C#/.NET?

查看:229
本文介绍了什么是红宝石(1.8.7)模拟SortedDictionary在C#/。NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要持有红宝石(1.8.7)的排序的散列值。哪些数据structed适合最好呢?

I need to hold values in sorted hash in ruby (1.8.7). What data structed will fit the best?

推荐答案

有什么比在核心库还是现在的标准库,将适合您法案。

There is nothing in the core library or the standard library now, that will fit your bill.

的,然而,的功能请求到红/黑树实现添加了Ruby 1.9.3 / 2.0。

There is, however, a feature request to add a Red/Black-Tree implementation to Ruby 1.9.3/2.0.

如果您能够强制用户只会使用 XRuby 或的 JRuby的,你可以只使用Java的的 java.util.SortedMap中的< K,V> 如的 java.util.TreeMap中的< K,V>

If you are able to force your users to only ever use XRuby or JRuby, you could just use one of the implementations of Java's java.util.SortedMap<K, V> such as java.util.TreeMap<K, V>.

如果您能够强制用户只使用过的 Ruby.NET IronRuby的,你可以只使用.NET的的 System.Collections.Generic.SortedDictionary< TKEY的,TValue方式>

If you are able to force your users to only ever use Ruby.NET or IronRuby, you could just use .NET's System.Collections.Generic.SortedDictionary<TKey, TValue>.

如果您能够强制用户只使用过MRI或YARV,你可以使用的 红宝石/ rBTree 库。它也可能对工作 Rubinius的或的的尚未发布的JRuby 1.6 。注意,似乎是在野生该库的多个独立更新叉子。这不是很明显,这其中的一个是最新的和/或最佳维持之一。

If you are able to force your users to only ever use MRI or YARV, you could use the Ruby/RBTree library. It might also work on Rubinius or the not-yet-released JRuby 1.6. Note that there seem to be multiple independent updated forks of that library in the wild. It is not obvious, which one of those is the most recent and/or best maintained one.

只有的解决方案,我知道这是保证是便携,是 Kanwei李的算法和容器编程之夏2008项目,这实际上包含了排序两种实现方式,关键索引的集合: 集装箱:: RBTreeMap基于一个红/黑树和的 =nofollow的> 集装箱:: SplayTreeMap 一个基于伸展树

The only solution I know of which is guaranteed to be portable, is Kanwei Li's Algorithms and Containers GSoC 2008 project, which actually contains two implementations of a sorted, key-indexed collection: Containers::RBTreeMap based on a Red/Black-Tree and Containers::SplayTreeMap based on a Splay Tree.

这篇关于什么是红宝石(1.8.7)模拟SortedDictionary在C#/。NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆