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


Groups > comp.lang.javascript > #40552

Re: Array object sorted on time, how to deal with.

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.javascript
Subject Re: Array object sorted on time, how to deal with.
Date 2021-11-23 11:22 +0000
Organization A noiseless patient Spider
Message-ID <878rxff75v.fsf@bsb.me.uk> (permalink)
References (2 earlier) <571380ac-a926-4bf2-88b2-a8a49b77a1bdn@googlegroups.com> <5dccbec9-7025-455d-96ef-5f5bc1fa4fe8n@googlegroups.com> <58bcaa57-860b-472f-9870-73e6551e7a48n@googlegroups.com> <daf4b01a-066d-461f-8291-712fc31ac8d8n@googlegroups.com> <6ee13397-3a3f-4ad5-8d46-8f9eb85debd8n@googlegroups.com>

Show all headers | View raw


luserdroog <luser.droog@gmail.com> writes:

> With a priority queue, at least the ones I looked at, when you create the
> queue you pass an ordering function to the constructor. It uses that function
> to figure out how to keep your data in order without knowing anything else
> about your data. So you can fill it with records and it'll keep everything in 
> a sorted order, you just have to tell it how to sort 2 of your things.

For an abstract priority queue (in the strictest sense) you don't need
to keep the queue sorted.

I went on the write "In fact, one common implementation uses a heap, as
in heap sort" but then I looked at your link and that uses a heap!  I
would not say that the data in a heap are in sorted order, though it's
almost a philosophical point.

However, if you need this:

> //then when you click play, you can get an array of everything 
> //in order and run through converting each note to midi events.
>
> function getNotesArray(){
>   return notesQueue.toArray()
> }

Then it might pay (depending on how the notes are generated) to maintain
a sorted array.  But why is a sorted array needed?  Can't whatever uses
this queue simply pull the notes off one at a time?

-- 
Ben.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Array object sorted on time, how to deal with. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-10-26 01:44 -0700
  Re: Array object sorted on time, how to deal with. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-10-26 01:48 -0700
    Re: Array object sorted on time, how to deal with. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-11-05 00:48 -0700
      Re: Array object sorted on time, how to deal with. luserdroog <luser.droog@gmail.com> - 2021-11-19 17:59 -0800
        Re: Array object sorted on time, how to deal with. luserdroog <luser.droog@gmail.com> - 2021-11-20 20:41 -0800
          Re: Array object sorted on time, how to deal with. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-11-21 04:28 -0800
            Re: Array object sorted on time, how to deal with. luserdroog <luser.droog@gmail.com> - 2021-11-22 20:36 -0800
              Re: Array object sorted on time, how to deal with. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-23 11:22 +0000
                Re: Array object sorted on time, how to deal with. The Natural Philosopher <tnp@invalid.invalid> - 2021-11-23 12:23 +0000
                Re: Array object sorted on time, how to deal with. luserdroog <luser.droog@gmail.com> - 2021-11-25 18:05 -0800
                Re: Array object sorted on time, how to deal with. John Harris <niam@jghnorth.org.uk.invalid> - 2021-11-26 18:18 +0000
                Re: Array object sorted on time, how to deal with. luserdroog <luser.droog@gmail.com> - 2021-11-26 16:02 -0800
                Re: Array object sorted on time, how to deal with. luserdroog <luser.droog@gmail.com> - 2021-11-25 18:17 -0800
                Re: Array object sorted on time, how to deal with. Richard Damon <Richard@Damon-Family.org> - 2021-11-25 22:27 -0500
                Re: Array object sorted on time, how to deal with. luserdroog <luser.droog@gmail.com> - 2021-11-25 20:14 -0800
                Re: Array object sorted on time, how to deal with. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-11-25 21:02 -0800
                Re: Array object sorted on time, how to deal with. luserdroog <luser.droog@gmail.com> - 2021-11-26 16:18 -0800
                Re: Array object sorted on time, how to deal with. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-11-25 20:41 -0800
                Re: Array object sorted on time, how to deal with. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-11-25 21:06 -0800

csiph-web