Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/skyfe79/CHDataStructures


https://github.com/skyfe79/CHDataStructures

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

        

README — CHDataStructures.framework


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;
}


CHDataStructures.framework


Version 1.4 — 09 Feb 2010


http://cocoaheads.byu.edu/code/CHDataStructures


© 2008–2010 Quinn Taylor — BYU CocoaHeads

© 2002 Phillip Morelock — Los Angeles, CA


Overview


CHDataStructures 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.


This library provides Objective-C implementations of common data structures which are currently beyond the purview of Apple's extensive and flexible Cocoa frameworks. 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:
deque,
heap,
linked list,
queue,
stack, and
tree.


The code is written against Apple's Foundation framework and uses some features of Objective-C 2.0 (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 GNUStep) but such efforts would be better accomplished by forking this project rather than integrating with it, for several main reasons:



  1. Supporting multiple environments increases code complexity, and consequently the effort required to test, maintain, and improve it.

  2. Libraries that have bigger and slower binaries to accommodate all possible platforms don't help the mainstream developer.

  3. Mac OS X is by far the most prevalent Objective-C environment in use, a trend which isn't likely to change soon.


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.



Getting the Code


All source code and resources for the framework are freely available at this link. They are organized in an Xcode 3 project with all relevant dependencies.


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!


The original page for the framework when it was maintained by Phillip Morelock (back when its name was "Cocoa Data Structures Framework") is here.

Using the Library


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.)


NOTE: When using this library, if you get a "Declaration does not declare anything" compiler warning, set the "C Language Dialect" (GCC_C_LANGUAGE_STANDARD) setting in your target's build settings to GNU99 [-std=gnu99].

Using the framework in a Mac application



  1. Open the Xcode project for your Mac application.

  2. Add CHDataStructures.framework to your project by dragging it to the "Groups & Files" pane.

  3. Expand the appropriate target and use a "Copy Files" build phase to copy the framework to the Contents/Frameworks/ directory in your application bundle. (The executable path in the framework binary expects this location.)

  4. Add #import <CHDataStructures/CHDataStructures.h> where necessary in your code.


For details or clarification about frameworks, consult the Framework Programming Guide.

Using the static library in an iOS app



  1. Open the Xcode project for your iOS app.

  2. Add libCHDataStructures.a and the library header files to your project by dragging them to the "Groups & Files" pane. (You can organize the headers in their own physical directory and sidebar group to prevent clutter.)

  3. Expand the appropriate target and drag libCHDataStructures.a into the "Link Binary With Libraries" build phase.

  4. Add #import "CHDataStructures.h" where necessary in your code.


If you have any issues with this approach, you can opt to drag CHDataStructures-iOS.xcodeproj into the "Groups & Files" pane and use the libCHDataStructures.a product from that project. In this case, you must also include PATH_TO_CHDATASTRUCTURES/source in Header Search Paths (HEADER_SEARCH_PATHS) for your target.

Documentation


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

Future Improvements


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 known bugs and wish list items that are documented in the code.

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, email me and we'll talk. Thanks!

License Information


This framework is released under a variant of the ISC license, an extremely simple and permissive free software license (functionally equivalent to the MIT license and two-clause BSD license) approved by the Open Source Initiative (OSI) and recognized as GPL-compatible by the GNU Project. The license is included in every source file, and is reproduced in its entirety here:


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.



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.

Earlier versions of this framework were released under a copyleft license, which are generally unfriendly towards commercial software development.


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.

Contributing to the Framework


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—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.


Email me 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.

Major contributors are listed below, alphabetically by last name:




  • Ole Begemann (Email, Website)

    • Assistance with adapting framework to work on iOS; contribution of a unit test iOS app.




  • Max Horn (Email, Website)

    • Ideas, example code, and impetus for conversions to C for speed.

    • Bugfixes and ideas for interface consistency.




  • Phillip Morelock (Email, Website)

    • Project inception, initial implementation, conversion of internals to straight C, maintenance.

    • Protocols and implementations for stacks, queues, linked lists, and trees.




  • Quinn Taylor (Email, Website)

    • Conversion to .xcodeproj format, organization of project resources, use of Objective-C 2.0 features.

    • Refactoring of protocols for performance, clarity, and compatibility with the Cocoa frameworks.

    • Improvements to code comments; configured auto-generated documentation using Doxygen.

    • Addition of OCUnit unit tests, code coverage, and a simple benchmarking driver.

    • Bugfixes and new features, including abstract classes and more Cocoa-like exception handling.




  • Julienne Walker (Email, Website)

    • Indirect contributions to binary search tree code, via code and tutorials in the public domain on her website. Many thanks!