473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

I'm looking for a pythonic red-black tree...

I need a red-black tree in Python and I was wondering if there was one
built in or if there's a good implementation out there. Something that,
lets face it, does whatever the C++ std::map<allows you to do...
Thank you...

Dec 15 '06 #1
5 3692
At Thursday 14/12/2006 22:20, Just Another Victim of the Ambient
Morality wrote:
I need a red-black tree in Python and I was wondering if there was one
built in or if there's a good implementation out there. Something that,
lets face it, does whatever the C++ std::map<allows you to do...
There are several implementations, try google...
--
Gabriel Genellina
Softlab SRL

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ˇgratis!
ˇAbrí tu cuenta ya! - http://correo.yahoo.com.ar
Dec 15 '06 #2

Just Another Victim of the Ambient Morality wrote:
I need a red-black tree in Python and I was wondering if there was one
built in or if there's a good implementation out there. Something that,
lets face it, does whatever the C++ std::map<allows you to do...
Thank you...

try,

http://py.vaults.ca/apyllo2.py/211227974
Cheers

Dec 15 '06 #3
On Fri, 15 Dec 2006 01:20:34 GMT, Just Another Victim of the Ambient Morality <ih*******@hotmail.comwrote:
I need a red-black tree in Python and I was wondering if there was one
built in or if there's a good implementation out there. Something that,
lets face it, does whatever the C++ std::map<allows you to do...
Nitpick: std::map is implemented using RB-trees, but it isn't one,
interface-wise.

/Jorgen

--
// Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn!
Dec 15 '06 #4
You could try and wrap the C/C++ code at
http://web.mit.edu/~emin/www/source_code/index.html and make a python
extension...

On Dec 14, 8:20 pm, "Just Another Victim of the Ambient Morality"
<ihates...@hotmail.comwrote:
I need a red-black tree in Python and I was wondering if there was one
built in or if there's a good implementation out there. Something that,
lets face it, does whatever the C++ std::map<allows you to do...
Thank you...
Dec 15 '06 #5
On Fri, 15 Dec 2006 01:20:34 +0000, Just Another Victim of the Ambient
Morality wrote:
I need a red-black tree in Python and I was wondering if there was one
built in or if there's a good implementation out there. Something that,
lets face it, does whatever the C++ std::map<allows you to do...
Are you really looking specifically for a red-black tree, or do you want a
container where iterators return values in sorted order? For instance, my
favorite sorted container is the skip-list:

* inherently thread safe even during container updates
* updates as fast as searches - significantly faster than red-black tree
* search as fast as trees on average - but probablistic (like hashtable)
* sequential access as fast as a linked list
* Uses 33% less memory than binary trees (like red-black tree)
* in general, performs like a hashtable, but sorted

Java example: http://bmsi.com/java/SkipList.java

In Python, the performance of a pure Python container will be
disappointing unless it leverages a native container. For many
applications, you can use a dict and sort when iterating (using heapq to
amortize the sorting).

If I ever get the time, I would seriously consider trying to modify Python
to replace the built-in dict with a skip-list algorithm and compare the
performance. Failing that, an extension module implementing a sorted
container of some description would be useful.

--
Stuart D. Gathman <st****@bmsi.com>
Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flamis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.

Dec 16 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: asdf sdf | last post by:
i need some advice. i'm a back end programmer historically, but have been exploring python for webapps and enjoying it. i need to build some simple Win client-server or standalone apps. the...
15
by: Ville Vainio | last post by:
Pythonic Nirvana - towards a true Object Oriented Environment ============================================================= IPython (by Francois Pinard) recently (next release - changes are...
12
by: Thomas Lotze | last post by:
Hi, I'm trying to figure out what is the most pythonic way to interact with a generator. The task I'm trying to accomplish is writing a PDF tokenizer, and I want to implement it as a Python...
3
by: andrew.fabbro | last post by:
I'm working on an app that will be deployed on several different servers. In each case, I'll want to change some config info (database name, paths, etc.) In perl, I would have done something...
4
by: Carl J. Van Arsdall | last post by:
It seems the more I come to learn about Python as a langauge and the way its used I've come across several discussions where people discuss how to do things using an OO model and then how to design...
33
by: Gregory Petrosyan | last post by:
Buenos dias, amigos! I have to write _simple_ gui library, for embedding into game. My first attempt was to use XML: isn't it cute to describe ui in such a way: <window> <title>Hello...
9
by: SMB | last post by:
I have two lists of data like the following: LIST1 , ] LIST2 , 'label': 'First Name', 'width': 0L, 'separator': ',', 'height': 0L, 'type': 2L, 'order': 1L}, {'code': 14L, 'name': 'Last...
2
by: G. Völkl | last post by:
Hello I am looking for examples of Pythonic Thinking: One example I found: Here some lines of the web side of Bruce Eckel: http://www.mindview.net/WebLog/log-0053 How to read a text file:
17
by: ToddLMorgan | last post by:
I'm just starting out with python, after having a long history with Java. I was wondering if there were any resources or tips from anyone out there in Python-land that can help me make the...
0
by: Jeff Rush | last post by:
(inspired by a thread on the psf-members list about Python certification) Those who know me know I am no fan of the programmer certification industry and I agree that your typical certificate...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.