Obj-C循环缓冲对象,实现一个? [英] Obj-C circular buffer object, implementing one?

查看:235
本文介绍了Obj-C循环缓冲对象,实现一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为iPhone开发了很长一段时间,我一直在想是否有任何数组对象在Obj-C中使用循环缓冲区?像Java的堆栈或列表或队列。
我一直在修补NSMutableArray,测试它的限制......似乎在数组中的50k个简单对象之后 - 应用程序显着减慢了。

I've been developing for the iPhone for quite some time and I've been wondering if there's any array object that uses circular buffer in Obj-C? Like Java's Stack or List or Queue. I've been tinkering with the NSMutableArray, testing it's limits... and it seems that after 50k simple objects inside the array - the application is significantly slowed down.

那么,除了NSMutableArray之外是否有更好的解决方案(大量数据变得非常慢)。如果没有,任何人都可以告诉我有关创建这样一个对象的方法(会涉及使用链(节点)对象??)。

So, is there any better solution other than the NSMutableArray (which becomes very slow with huge amounts of data). If not, can anyone tell me about a way to create such an object (would that involve using chain (node) objects??).

底线:填充UITableView从SQLite DB直接会是聪明的吗?因为它不需要来自数组或任何内容的内存,只需要查询。而SQLite速度快,而不是内存磨损。

Bottom line: Populating a UITableView from an SQLite DB directly would be smart? As it won't require memory from an array or anything, but just the queries. And SQLite is fast and not memory grinding.

非常感谢您的时间和精力,
~Natanavra。

Thank you very much for you time and attention, ~ Natanavra.

从我一直以来的看来,Quinn的课程似乎是最好的选择。
我有另一个问题 - 从SQLite DB直接加载所有东西而不是创建一个对象并将其推入数组会更快或更聪明吗?

From what I've been thinking it seems that going for Quinn's class is the best option possibly. I have another question - would it be faster or smarter to load everything straight from the SQLite DB instead of creating an object and pushing it into an array?

提前谢谢,
~Natanavra。

Thank you in advance, ~ Natanavra.

推荐答案

道歉我自己的号角,但我实施了C-基于 CHDataStructures 的循环缓冲区。 (具体来说,请查看 CHCircularBufferQueue CHCircularBufferStack 。)该项目是开源的,并有基准,证明了一个真正的循环在一般情况下,与NSMutableArray相比,缓冲区非常快,但结果将取决于您的数据和使用情况,以及您在内存受限设备(例如iPhone)上运行的事实。希望有所帮助!

Apologies for tooting my own horn, but I implemented a C-based circular buffer in CHDataStructures. (Specifically, check out CHCircularBufferQueue and CHCircularBufferStack.) The project is open source and has benchmarks which demonstrate that a true circular buffer is quite fast when compared to NSMutableArray in the general case, but results will depend on your data and usage, as well as the fact that you're operating on a memory-constrained device (e.g. iPhone). Hope that helps!

这篇关于Obj-C循环缓冲对象,实现一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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