Skip to content
An Objective-C library of data structures, such as deque, heap, linked list, queue, stack, and tree.
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
benchmarks Changed Benchmarks.m to horizontally "jitter" the X coordinate of tre… Nov 20, 2008
doxygen Updated Doxyfile for Doxygen 1.7.3; removed broken and unused MSCGEN_… Jan 11, 2011
resources Merged Mac and iOS targets into one Xcode project (iOS now builds as … Jan 22, 2015
source Removed garbage collection support and references. Jan 22, 2015
CHDataStructures.podspec Added CocoaPods CHDataStructures podspec. Jan 22, 2015
coverage.html Configured Xcode to run lcov after gcov, and generate an HTML coverag… Nov 13, 2008
docs.html Added project and code for Cocoa Data Structures framework. Sep 24, 2008


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
	<title>README &mdash; CHDataStructures.framework</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<style type="text/css" media="all">
		body {
			font-family: "Lucida Grande", Verdana, Geneva, Arial, sans-serif;
			font-size: 12px;
		p {
			margin-left: 10px;
		li {
			margin-top: 5px;
		li li {
			margin-top: 0;
		code {
			color: #007;
<div align="center">
<h2>Version 1.4 &mdash; 09 Feb 2010</h2>
<h4><a href=""></a></h4>
<h4>&copy; 2008&ndash;2010 <a href="">Quinn Taylor</a> &mdash; BYU CocoaHeads<br />
&copy; 2002 <a href="">Phillip Morelock</a> &mdash; Los Angeles, CA</h4>

<p><strong>CHDataStructures</strong> is a library of standard data structures which can be used in (virtually) any Objective-C program. Data structures in this library adopt Objective-C protocols that define the functionality of and API for interacting with any implementation thereof, regardless of its internals.</p>
<p>This library provides Objective-C implementations of common data structures which are currently beyond the purview of Apple's extensive and flexible <a href="">Cocoa frameworks</a>. Collections that are a part of Cocoa are highly optimized and amenable to many situations. However, sometimes an honest-to-goodness stack, queue, linked list, tree, etc. can greatly improve the clarity and comprehensibility of code. The currently supported abstract data types include:
	<a href="">deque</a>,
	<a href="">heap</a>,
	<a href="">linked list</a>,
	<a href="">queue</a>,
	<a href="">stack</a>, and
	<a href="">tree</a>.</p>
<p>The code is written against Apple's <a href="">Foundation framework</a> and uses some features of <a href="">Objective-C 2.0</a> (present in OS X 10.5+ and iOS) when possible. Most of the code could be easily ported to other Objective-C environments (such as <a href="">GNUStep</a>) but such efforts would be better accomplished by forking this project rather than integrating with it, for several main reasons:</p>
	<li>Supporting multiple environments increases code complexity, and consequently the effort required to test, maintain, and improve it.</li>
	<li>Libraries that have bigger and slower binaries to accommodate all possible platforms don't help the mainstream developer.</li>
	<li>Mac OS X is by far the most prevalent Objective-C environment in use, a trend which isn't likely to change soon.</li>
<p>While certain implementations utilize straight C for their internals, this framework is fairly high-level, and uses composition rather than inheritance in most cases. The framework began its existence as an exercise in writing Objective-C code and consisted mainly of ported Java code. In later revisions, performance has gained greater emphasis, but the primary motivation is to provide friendly, intuitive Objective-C interfaces for data structures, not to maximize speed at any cost (a common outcome when using C++ and the STL). The algorithms should all be sound (i.e., you won't get O(n) performance when it should be O(log n) or O(1), etc.) and perform quite well in general. If your choice of data structure type and implementation are dependent on performance or memory usage, it would be wise to run the benchmarks from Xcode and choose based on the time and memory complexity for specific implementations.</p>
<h2>Getting the Code</h2>
<p>All source code and resources for the framework are freely available at <a href="">this link</a>. They are organized in an Xcode 3 project with all relevant dependencies.</p>
<p>If you only need a few of the classes in the framework, you can cut down on code size by either excluding parts you don't need from the framework, or just including the source you do need in your own code. Please don't forget to include relevant copyright and license information if you choose to do so!</p>
<p>The original page for the framework when it was maintained by Phillip Morelock (back when its name was "Cocoa Data Structures Framework") is <a href=""> here.</a></p>

<h2>Using the Library</h2>
<p>CHDataStructures builds for both OS X (as a framework) and iOS (as a static library, since third-party frameworks are not permitted). The following directions assume that you have either built the appropriate library form (framework or static library) from source, or are using a binary distribution. (When building from source, compile the All target in the Release configuration, which produces a disk image containing the binaries.)</p>
<p>NOTE: When using this library, if you get a "Declaration does not declare anything" compiler warning, set the "C Language Dialect" (<code>GCC_C_LANGUAGE_STANDARD</code>) setting in your target's build settings to <code>GNU99 [-std=gnu99]</code>.</p>

<h3>Using the framework in a Mac application</h3>
  <li>Open the Xcode project for your Mac application.</li>
  <li>Add <code>CHDataStructures.framework</code> to your project by dragging it to the "Groups &amp; Files" pane.</li>
  <li>Expand the appropriate target and use a "Copy Files" build phase to copy the framework to the <code>Contents/Frameworks/</code> directory in your application bundle. (The executable path in the framework binary expects this location.)</li>
  <li>Add <code>#import &lt;CHDataStructures/CHDataStructures.h&gt;</code> where necessary in your code.</li>
<p>For details or clarification about frameworks, consult the <a href="">Framework Programming Guide</a>.</p>

<h3>Using the static library in an iOS app</h3>
  <li>Open the Xcode project for your iOS app.</li>
  <li>Add <code>libCHDataStructures.a</code> and the library header files to your project by dragging them to the "Groups &amp; Files" pane. (You can organize the headers in their own physical directory and sidebar group to prevent clutter.)</li>
  <li>Expand the appropriate target and drag <code>libCHDataStructures.a</code> into the "Link Binary With Libraries" build phase.</li>
  <li>Add <code>#import "CHDataStructures.h"</code> where necessary in your code.</li>
<p>If you have any issues with this approach, you can opt to drag <code>CHDataStructures-iOS.xcodeproj</code> into the "Groups &amp; Files" pane and use the <code>libCHDataStructures.a</code> product from that project. In this case, you must also include <code>PATH_TO_CHDATASTRUCTURES/source</code> in Header Search Paths (<code>HEADER_SEARCH_PATHS</code>) for your target.</p>

<p>Documentation is auto-generated after each Subversion commit, and is <a href="">available online</a>. You can also generate it yourself from the main Xcode project by building the "Documentation" target (if <a href="">Doxygen</a> is installed and its executable is in your Unix <code>$PATH</code> variable).</p>

<h2>Future Improvements</h2>
<p>Let's just say it: no software is perfect. It would be foolish (and a lie) to claim that this framework is flawless, or even complete. There are several things that could be improved, and admitting you have a problem is the first step.... Accordingly, the online documentation includes lists of <a href="">known bugs</a> and <a href="">wish list items</a> that are documented in the code.</p>

<p>Please know that it is not my intent to leave the hard things "as an exercise to the reader." (Believe me, writing a generic, iterative, state-saving tree traversal enumerator was no walk in the park!) However, I would love to draw on the talents of others who can provide solutions which currently evade me, or which I haven't had time to implement yet. If you have ideas (or even better, a fix) for one of these items, <a href="">email me</a> and we'll talk. Thanks!</p>

<h2>License Information</h2>
<p>This framework is released under a variant of the <a href="">ISC license</a>, an extremely simple and permissive free software license (functionally equivalent to the <a href="">MIT license</a> and two-clause <a href="">BSD license</a>) approved by the <a href="">Open Source Initiative (OSI)</a> and recognized as GPL-compatible by the <a href="">GNU Project</a>. The license is included in every source file, and is reproduced in its entirety here:</p>
<blockquote><em>Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.<br/>
The software is provided "as is", without warranty of any kind, including all implied warranties of merchantability and fitness. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.</em></blockquote>
<p>Earlier versions of this framework were released under a <a href="">copyleft license</a>, which are generally unfriendly towards commercial software development.</p>
<p>This README file is also considered a source file, and you must include it if you redistribute the framework in source form. If you change the framework, you should add your own README and include it with the source, describing your changes. If you contribute source code to the framework, you may keep your copyright or assign it to me, but you must agree to license the code under this license.</p>

<h2>Contributing to the Framework</h2>
<p>All contributions (including bug reports and fixes, optimizations, new data structures, etc.) are welcomed and encouraged. In keeping with this project's goals, new features are subject to consideration prior to approval&mdash;there are no guarantees of adoption. Modifications that are deemed beneficial to the community as a whole will fit with the vision of this project and improve it. However, not all potential contributions make sense to add to the framework. For example, additions or enhancements that only apply for a specific project would be more appropriate to add as categories or subclasses in that code.</p>
<p><a href=""> Email me</a> if you're interested in contributing to the project, discussing improvements or additions you'd like to see, or even just letting me know that you're getting some use from it.</p>

<p>Major contributors are listed below, alphabetically by last name:</p>
  <li><strong>Ole Begemann</strong> (<a href="">Email</a>, <a href="">Website</a>)
      <li>Assistance with adapting framework to work on iOS; contribution of a unit test iOS app.</li>
  <li><strong>Max Horn</strong> (<a href="">Email</a>, <a href="">Website</a>)
      <li>Ideas, example code, and impetus for conversions to C for speed.</li>
      <li>Bugfixes and ideas for interface consistency.</li>
  <li><strong>Phillip Morelock</strong> (<a href="">Email</a>, <a href="">Website</a>)
      <li>Project inception, initial implementation, conversion of internals to straight C, maintenance.</li>
      <li>Protocols and implementations for stacks, queues, linked lists, and trees.</li>
  <li><strong>Quinn Taylor</strong> (<a href="">Email</a>, <a href="">Website</a>)
      <li>Conversion to <code>.xcodeproj</code> format, organization of project resources, use of Objective-C 2.0 features.</li>
	  <li>Refactoring of protocols for performance, clarity, and compatibility with the Cocoa frameworks.</li>
	  <li>Improvements to code comments; configured auto-generated documentation using <a href="">Doxygen</a>.</li>
	  <li>Addition of <a href="">OCUnit</a> unit tests, code coverage, and a simple benchmarking driver.</li>
	  <li>Bugfixes and new features, including abstract classes and more Cocoa-like exception handling.</li>
  <li><strong>Julienne Walker</strong> (<a href="">Email</a>, <a href="">Website</a>)
      <li>Indirect contributions to binary search tree code, via code and tutorials in the public domain on her website. Many thanks!</li>

You can’t perform that action at this time.