Comments (4)
I see the following problems:
nil
can not be a key of a table, soheap.reverse
wont worknil
is returned from methods likepop
andpeek
when no value exists. If we allow nil as a valid payload, then this behaviour is to be changed- using
nil
as a valid valud is not Lua-ish
👎
from binaryheap.lua.
The idea was to use the same implementation for a heap with payload as one without a payload (in the latter case payload == nil)
nil can not be a key of a table, so heap.reverse wont work
if you test for nil first... just return nil
using nil as a valid valud is not Lua-ish
it is for omitting parameters
but as noted in my initial posting, it does have some issues... don't know the performance impact of those
from binaryheap.lua.
The idea was to use the same implementation for a heap with payload as one without a payload (in the latter case payload == nil)
I think, type of a heap should be determined when a heap is created. Otherwise, how to deal with same heap being used as both plain heap and unique heap?
from binaryheap.lua.
@starius re reading this, I think it is indeed not a good idea. Closing.
from binaryheap.lua.
Related Issues (11)
- use 2 tables instead of a table per item
- heap:pop() is documented twice
- field "reverse" HOT 2
- we need a method which would convert a payload to a value HOT 2
- how to remove by pos in unique heap? HOT 2
- we need unique heap subtype where payload=value HOT 4
- remove, pop and peek results order HOT 3
- unique:peek() is not documented HOT 1
- unique:pop() return value HOT 2
- Test for dijkstras algorithm fails on Lua 5.3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from binaryheap.lua.