Cocoa Touch有一个搜索树数据结构? [英] Does Cocoa Touch have a search tree data structure?

查看:108
本文介绍了Cocoa Touch有一个搜索树数据结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在谷歌看到这一点,并阅读了SDK文档中的集合条目,没有任何改变。有没有一个BST(其任何一个变体)实现可以与iOS SDK开箱即用?

I've been looking into this on Google and read the Collections entry in the SDK documentation, and turned up nothing. Is there a BST (any of its variants) implementation available out of the box with the iOS SDK?

似乎奇怪的是,一个如此基本的东西将从一个主要的开发中失踪平台。他们的哈希实现是那么神奇吗?或者开发商假设没有人会在有订单的东西上插入/删除?

It seems odd that something so basic would be missing from a major development platform. Is their hash implementation just that magical? Or do the devs assume no one is going to do inserts/deletes on things that have an order?

我可以使用 NSSet 现在,因为我知道我们大多数人(包括我自己)并没有真正写出任何需要保证访问时间的iOS上的计算量,但是它依然在我耳边。

I can use NSSet for now, as I know most of us (myself included) aren't really writing anything with tons of computation on iOS that need a guaranteed access time, but it's still gnawing at me.

推荐答案

CFBinaryHeap看起来很有前途,有用,但可能并不完全是你想要的,因为它不是一个二进制搜索树,而是一个。他们是相似的,但不一样,所以我觉得Core Foundation的 CFTree 类可能会更好一点。以下是CFTree类引用的描述:

CFBinaryHeap looks pretty promising and useful, but it might not be exactly what you want, as it's not really a binary search tree but a heap. They are similar, but not the same, so I feel like Core Foundation's CFTree class might be a little better. Here's a description from the CFTree class reference:


您可以使用CFTree创建代表层次结构信息的树结构。在这样的结构中,每个树节点只有一个父树(除了根树,没有父项),并且可以有多个子节点。

You use CFTree to create tree structures that represent hierarchical organizations of information. In such structures, each tree node has exactly one parent tree (except for the root tree, which has no parent) and can have multiple children.

如果您对C(Core Foundation is C,而不是Objective-C)不舒服,可以使用CFTree的Objective-C包装器JKPTree库。您可以下载 here

If you're not comfortable with C (Core Foundation is C, not Objective-C), you can use the JKPTree library which is an Objective-C wrapper of CFTree. You can download it here.

我刚刚发现另一个名为 CHDataStructures

I just found another library called CHDataStructures that simplifies the creation of a wide variety of data structures. It supports the following data structures (and many other unlisted ones):


  • AVL树

  • 摘要二元搜索树

  • 安德森树

  • 链接列表

  • 搜索树

  • 红黑树

  • 不平衡树

  • 队列

  • AVL Tree
  • Abstract Binary Search Tree
  • Andersson Tree
  • Linked List
  • Search Tree
  • Red Black Tree
  • Unbalanced Tree
  • Queue
  • Heap

您可以下载CHDataStructures here

You can download CHDataStructures here.

这篇关于Cocoa Touch有一个搜索树数据结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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