Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions files/docs/binary-heaps/MIT-LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2012-2013 Roland Yonaba

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
98 changes: 98 additions & 0 deletions files/docs/binary-heaps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#Binary-Heaps#
Implementation of *binary heaps* data structure in pure Lua


##Usage##
Add 'binary_heap.lua' file inside your project.
Call it using __require__ function.
It will return a table containing a set of functions, acting as a class.

##API##


* __heap:new()__ : Returns a new heap ( a Min-Heap by default).
* __heap()__ : Same as heap:new()
* __heap:empty()__ : Checks if a heap is empty.
* __heap:getSize()__ : Returns the size of the heap.
* __heap:clear()__ : Clears a heap
* __heap:leftChildIndex(index)__ : Returns the left child index of element at position index in the heap
* __heap:rightChildIndex(index)__ : Returns the right child index of element at position index in the heap
* __heap:parentIndex(index)__ : Returns the parent index of element at position index in the heap
* __heap:insert(value,linkedData)__ : Inserts value with linked data in the heap and percolates it up at its proper place.
* __heap:add(value, linkedData)__ : Alias to <tt>heap.insert</tt>
* __heap:replace(value,linkedData)__ : Saves the top of the heap, adds a new element at the top and reorders the heap.
* __heap:pop()__ : Pops the top element, reorders the heap and returns this element unpacked : value first then data linked
* __heap:checkIndex()__ : checks existence of an element at position index in the heap.
* __heap:reset(function)__ : Reorders the current heap regards to the new comparison function given as argument
* __heap:merge(other)__ : merge the current heap with another
* __heap:isValid()__ : Checks if a heap is valid
* __heap:heap(item)__ : Restores the heap property (in case the heap was earlier found non-valid)

##Additionnal features##

```lua
h1+h2 : Returns a new heap with all data stored inside h1 and h2 heaps
tostring(h) : Returns a string representation of heap h
print(h) : Prints current heap h as a string
```
By default, you create Min-heaps. If you do need __Max-heaps__, you can easily create them this way:

```lua
local comp = function(a,b) return a>b end
local myHeap = heap(comp)
```

##Chaining##
Some functions can be chained together, as they return the heap itself:

```lua
heap:clear()
heap:add() or heap:insert()
heap:reset()
heap:merge()
heap:heap()
```

Example:

```lua
h = Heap()
h:add(1):add(2):heap():clear():add(3):add(4):merge(Heap()):reset()
print(h)
```

#Documentation used#
* [Algolist.net data structure course][]
* [Victor S.Adamchik's Lecture on Cs.cmu.edu][]
* [RPerrot's Article on Developpez.com][]

##License##
This work is under MIT-LICENSE
Copyright (c) 2012 Roland Yonaba

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

[Algolist.net data structure course]: http://www.algolist.net/Data_structures/Binary_heap/Array-based_int_repr
[Victor S.Adamchik's Lecture on Cs.cmu.edu]: http://www.cs.cmu.edu/~adamchik/15-121/lectures/Binary%20Heaps/heaps.html
[RPerrot's Article on Developpez.com]: http://rperrot.developpez.com/articles/algo/structures/arbres/
[Lua Class System]: http://yonaba.github.com/Lua-Class-System/

[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/Yonaba/binary-heaps/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

35 changes: 35 additions & 0 deletions files/docs/binary-heaps/version_history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#Version history#

##1.5.1 (03/27/2013)
* `heap()` handles an optional arg `item`
* `heap()` now returns in case it wa found empty.

##1.5 (08/27/12)
* Added chaining
* Added <tt>Heap:add()</tt> as alias to <tt>Heap:insert()</tt>
* Buxfix with <tt>Heap:reset()</tt>
* Deleted unused <tt>Heap:init()</tt>
* Code cleaning, Indentation Fixed

##1.4 (08/01/2012)
* Made the current module independant from [LuaClassSystem][]

##1.3 (06/13/2012)
* Name clashing fixed : size() was renamed getSize()

##1.2 (05/28/12)
* Updated third-party library (Lua Class System)
* Added version_history.md

##1.1 (05/25/12)
* Converted to module

##1.0 (05/21/12)
* Heap class and instances now managed with Lua Class System
* Internal class structure modified, items now stored in a private "_heap" field
* Added heap:init(), heap:top(), heap:replace(), heap:heap()

##0.3 (05/14/12)
* Initial Release

[LuaClassSystem]: https://github.com/Yonaba/Lua-Class-System
20 changes: 20 additions & 0 deletions files/docs/strictness/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CHANGELOG
=========

###0.2.0 (06/11/14)
* `strictness` no longer create globals. It returns a local table of library functions.
* `strictness` can now create (or convert) strict/unstrict tables (or environnements).
* Strict/unstrict rules are now applied per table (or environnement).
* Strict mode enforces variable declarations and complain on undefined fields access/assignment.
* Tables (or environnements) already existing metatables are preserved, including `__index` and `__newindex` fields.
* Added `strictness.strict` to convert a normal table (or environnement) to a strict one.
* Added `strictness.unstrict` to convert a strict table (or environnement) to a normal one.
* Added `strictness.is_strict` to check if a table (or environnement) is strict.
* Added `strictness.strictf` to wrap a normal function into a non strict function.
* Added `strictness.unstrictf` to wrap a normal function into a strict function.
* Added `strictness.run_strict` to run a normal function in strict mode.
* Added `strictness.run_unstrict` to run a normal function in non strict mode.
* Made compliant with Lua 5.2 new _ENV lexical scoping (although strictly speaking there are no globals in Lua 5.2).

###0.1.0 (10/05/13)
* Initial release
20 changes: 20 additions & 0 deletions files/docs/strictness/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2013-2014 Roland Y.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
63 changes: 63 additions & 0 deletions files/docs/strictness/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
strictness
===========

[![Build Status](https://travis-ci.org/Yonaba/strictness.png)](https://travis-ci.org/Yonaba/strictness)
[![Coverage Status](https://coveralls.io/repos/Yonaba/strictness/badge.png?branch=master)](https://coveralls.io/r/Yonaba/strictness?branch=master)
[![License](http://img.shields.io/badge/Licence-MIT-brightgreen.svg)](LICENSE)

With the __Lua__ programming language, undeclared variables are not detected until runtime, as Lua will not complain when loading code.
This is releated to the convention that Lua uses : [global by default](http://www.lua.org/pil/1.2.html). In other words, when a variable is not recognized as *local*, it will be
interpreted as a *global* one, and will involve a lookup in the global environment `_G` (for Lua 5.1). Note that this behaviour has been addressed
in Lua 5.2, which strictly speaking has no globals, because of its [lexical scoping](http://www.luafaq.org/#T8.2.1).

*strictness* is a module to track *access and assignment* to undefined variables in your code. It *enforces* to declare globals and modules variables before
assigning them values. As such, it helps having a better control on the scope of variables across the code.

*strictness* is mostly meant to work with Lua [5.1](http://www.lua.org/versions.html#5.1), but it is compatible with Lua [5.2](http://www.lua.org/versions.html#5.2).

##Installation

####Git

git clone git://github.com/Yonaba/strictness

####Download

* See [releases](https://github.com/Yonaba/strictness/releases)

####LuaRocks

luarocks install strictness

####MoonRocks

moonrocks install strictness

or

luarocks install strictness --server=http://rocks.moonscript.org strictness


## Documentation

See [tutorial.md](doc/tutorial.md).

##Tests

This project has specification tests. To run these tests, execute the following command from the project root folder:

lua spec/tests.lua

##Similar projects

Feel free to check those alternate implementations, from with *strictness* takes some inspiration:

* [strict.lua](http://rtfc.googlecode.com/svn-history/r2/trunk/lua-5.1/etc/strict.lua) which is included in the official Lua 5.1 distribution,
* [pl.strict](https://github.com/stevedonovan/Penlight/blob/master/lua/pl/strict.lua) which is part of [Penlight](https://github.com/stevedonovan/Penlight),

##License
This work is under [MIT-LICENSE](http://www.opensource.org/licenses/mit-license.php)<br/>
*Copyright (c) 2013-2014 Roland Yonaba*.
See [LICENSE](LICENSE).

[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/Yonaba/strictness/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
Loading