Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102703

Re: Heap Implementation

From Cem Karan <cfkaran2@gmail.com>
Newsgroups comp.lang.python
Subject Re: Heap Implementation
Date 2016-02-08 23:25 -0500
Message-ID <mailman.118.1454991952.2317.python-list@python.org> (permalink)
References <56AD3D83.2050308@mail.de> <7C522D08-9D73-48D2-A71D-F1D1D34C02A5@gmail.com> <CACs7g=Cu=tGhU3TtBa0cYr46WP7kOHWyxz2TiHXCuiSLqb4P7A@mail.gmail.com> <185DAEA4-8728-4792-A3B7-7F6AC5A7F876@gmail.com> <CACs7g=APHr+DbmZaGz7P3RaRUGDYPqH+eniVTFenppPXXinOvQ@mail.gmail.com>

Show all headers | View raw


On Feb 8, 2016, at 10:12 PM, srinivas devaki <mr.eightnoteight@gmail.com> wrote:

> 
> On Feb 8, 2016 5:17 PM, "Cem Karan" <cfkaran2@gmail.com> wrote:
> >
> > On Feb 7, 2016, at 10:15 PM, srinivas devaki <mr.eightnoteight@gmail.com> wrote:
> > > On Feb 8, 2016 7:07 AM, "Cem Karan" <cfkaran2@gmail.com> wrote:
> > > > I know that there are methods of handling this from the client-side (tuples with unique counters come to mind), but if your library can handle it directly, then that could be useful to others as well.
> > >
> > > yeah it is a good idea to do at client side.
> > > but if it should be introduced as feature into the library, instead of tuples, we should just piggyback a single counter it to the self._indexes dict, or better make another self._counts dict which will be light and fast.
> > > and if you think again with this method you can easily subclass with just using self._counts dict  in your subclass. but still I think it is good to introduce it as a feature in the library.
> > >
> > > Regards
> > > Srinivas Devaki
> >
> > I meant that the counter is a trick to separate different instances of (item, priority) pairs when you're pushing in the same item multiple times, but with different priorities.
> 
> oh okay, I'm way too off.
> 
> what you are asking for is a Priority Queue like feature.
> 
> but the emphasis is on providing extra features to heap data structure.
> 
> and xheap doesn't support having duplicate items.
> 
> and if you want to insert same items with distinct priorities, you can provide the priority with key argument to the xheap. what xheap doesn't support is having same keys/priorities.
> So I got confused and proposed a method to have same keys.
> 
> Regards
> Srinivas Devaki

No problem, that's what I thought happened.  And you're right, I'm looking for a priority queue (not the only reason to use a heap, but a pretty important reason!)

Thanks,
Cem Karan

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Heap Implementation Cem Karan <cfkaran2@gmail.com> - 2016-02-08 23:25 -0500

csiph-web