Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #52408
| Newsgroups | comp.lang.forth |
|---|---|
| Date | 2016-11-02 14:56 -0700 |
| References | (3 earlier) <f3a8805a-f41f-4580-ba39-1bf65bfeb81d@googlegroups.com> <03293c78-90ce-4f63-b960-e6af25053361@googlegroups.com> <16671467-ce11-459a-a31b-94f76142b3c5@googlegroups.com> <ffc46405-5420-4d3f-9324-1fcfeb58ecbe@googlegroups.com> <c0df23b7-6b2c-4dc2-9ade-0c94cd55971f@googlegroups.com> |
| Message-ID | <6299e4e1-ff67-489d-9b8b-208fa7d3d33d@googlegroups.com> (permalink) |
| Subject | Re: A flexible bsearch |
| From | josv@planet.nl |
Hi, "a bit too much" means in this case too much for my application. Not for the use of a binary-tree. > Your sensor data is obtained at run-time, not compile-time, so use a binary-tree rather than an array. Not in my case. Since it is not allowed to make insertions and deletions. Each minute new data is taken from the sensor. Then it is then appended to a data-file. A webserver is able to access that file through a mapping. Then it sees it as one big array outside the dictionary for finding and sending data. Jos On 2 november 2016 19:51:33 UTC+1 hughag...@gmail.com wrote: > On Wednesday, November 2, 2016 at 7:56:49 AM UTC-7, jo...@planet.nl wrote: > > Hi, > > > > I only need the bsearch to search a datafile from a sensor. > > ASSOCIATION.4TH is nice but a bit too much. > > I don't really understand the concept of "a bit too much" when you aren't the guy writing the code. > > The major problem with ANS-Forth is that data-structures are disallowed. Elizabeth Rather says: > ---------------------------------------------------------------------------- > Virtually every Forth application needs some kind of array structures. The > reason that some general-purpose one might be "little used" is because it's > so easy to make a version that does *exactly* what the application needs > rather than some generic definition. ... The objective is to master the > toolset and be able to think clearly about exactly what kind of arrays will be > useful in your application and then build exactly that kind. > ---------------------------------------------------------------------------- > > Why would "every" Forth application need arrays? I almost never use arrays. She says this because all of her knowledge of Forth comes from reading "Starting Forth" and arrays were the only data-structure provided. She doesn't actually know how to implement any other data-structure. > > Arrays have these advantages over binary trees: > 1.) They take up less memory because there are no pointers to nodes. > 2.) The elements are juxtaposed, so they can share data-cache lines. > 3.) A SORT function is easier to implement than a self-balancing binary tree. > > The major disadvantage of arrays compared to binary trees is: > 1.) Insertion and deletion is complicated and inefficient. > > So, if insertion and deletion are needed, use a binary tree. For the most part, arrays are only useful for look-up tables --- these are typically generated at compile-time --- typically SORT is only executed once, at compile-time when the speed is not an issue. > > Your sensor data is obtained at run-time, not compile-time, so use a binary-tree rather than an array. > > In Straight Forth the two built-in data-structures are the "chain" and the array --- the chain is typically an AVL tree with an UP pointer to make traversal possible --- this is not "a bit too much," but is actually the minimum needed (should be adequate for at least 99% of all Straight Forth programs).
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A flexible bsearch josv@planet.nl - 2016-10-27 11:26 -0700
Re: A flexible bsearch hughaguilar96@gmail.com - 2016-10-27 17:29 -0700
Re: A flexible bsearch hughaguilar96@gmail.com - 2016-10-27 20:38 -0700
Re: A flexible bsearch josv@planet.nl - 2016-10-28 03:11 -0700
Re: A flexible bsearch hughaguilar96@gmail.com - 2016-10-31 12:08 -0700
Re: A flexible bsearch hughaguilar96@gmail.com - 2016-10-31 12:42 -0700
Re: A flexible bsearch hughaguilar96@gmail.com - 2016-10-31 13:27 -0700
Re: A flexible bsearch josv@planet.nl - 2016-10-31 18:35 -0700
Re: A flexible bsearch humptydumpty <ouatubi@gmail.com> - 2016-10-31 11:22 -0700
Re: A flexible bsearch hughaguilar96@gmail.com - 2016-10-31 12:59 -0700
Re: A flexible bsearch josv@planet.nl - 2016-10-31 18:27 -0700
Re: A flexible bsearch hughaguilar96@gmail.com - 2016-10-31 18:54 -0700
Re: A flexible bsearch josv@planet.nl - 2016-11-01 07:04 -0700
Re: A flexible bsearch hughaguilar96@gmail.com - 2016-11-01 10:15 -0700
Re: A flexible bsearch josv@planet.nl - 2016-11-02 07:56 -0700
Re: A flexible bsearch hughaguilar96@gmail.com - 2016-11-02 11:51 -0700
Re: A flexible bsearch hughaguilar96@gmail.com - 2016-11-02 12:20 -0700
Re: A flexible bsearch josv@planet.nl - 2016-11-02 14:56 -0700
Re: A flexible bsearch hughaguilar96@gmail.com - 2016-11-03 11:16 -0700
Re: A flexible bsearch josv@planet.nl - 2016-11-03 16:25 -0700
Re: A flexible bsearch hughaguilar96@gmail.com - 2016-11-03 16:56 -0700
Re: A flexible bsearch hughaguilar96@gmail.com - 2016-11-03 17:14 -0700
Re: A flexible bsearch hughaguilar96@gmail.com - 2016-11-05 18:41 -0700
Re: A flexible bsearch hughaguilar96@gmail.com - 2016-11-05 19:06 -0700
Re: A flexible bsearch josv@planet.nl - 2016-11-06 01:28 -0800
Re: A flexible bsearch hughaguilar96@gmail.com - 2016-11-06 15:49 -0800
Re: A flexible bsearch trans <transfire@gmail.com> - 2016-11-06 17:18 -0800
Re: A flexible bsearch hughaguilar96@gmail.com - 2016-11-06 18:44 -0800
Re: A flexible bsearch josv@planet.nl - 2016-11-07 03:57 -0800
Re: A flexible bsearch jim <anon@example.com> - 2016-11-07 12:56 +0000
Re: A flexible bsearch josv@planet.nl - 2016-11-07 09:17 -0800
Re: A flexible bsearch jim <anon@example.com> - 2016-11-07 19:58 +0000
Re: A flexible bsearch josv@planet.nl - 2016-11-07 12:36 -0800
Re: A flexible bsearch albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-11-07 11:12 +0100
Re: A flexible bsearch humptydumpty <ouatubi@gmail.com> - 2016-11-01 01:12 -0700
Re: A flexible bsearch josv@planet.nl - 2016-11-01 07:09 -0700
Re: A flexible bsearch humptydumpty <ouatubi@gmail.com> - 2016-11-01 10:14 -0700
Re: A flexible bsearch humptydumpty <ouatubi@gmail.com> - 2016-11-01 10:18 -0700
Re: A flexible bsearch josv@planet.nl - 2016-11-02 07:49 -0700
Re: A flexible bsearch albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-11-02 19:00 +0100
Re: A flexible bsearch josv@planet.nl - 2016-11-03 05:36 -0700
Re: A flexible bsearch albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-11-03 18:32 +0100
Re: A flexible bsearch josv@planet.nl - 2016-11-03 16:17 -0700
Re: A flexible bsearch "Elizabeth D. Rather" <erather@forth.com> - 2016-11-03 21:53 -1000
Re: A flexible bsearch albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-11-04 11:42 +0100
Re: A flexible bsearch josv@planet.nl - 2016-11-04 04:37 -0700
Re: A flexible bsearch "WJ" <w_a_x_man@yahoo.com> - 2016-11-10 20:22 +0000
csiph-web