Highly specific, but useful, collections-related classes.

Introduced classes

class BestDistance[E: nullable Object]

more_collections :: BestDistance

Keep track of the best elements according to a distance value.
class DefaultMap[K: nullable Object, V: nullable Object]

more_collections :: DefaultMap

A map with a default value.
class HashMap2[K1: nullable Object, K2: nullable Object, V: nullable Object]

more_collections :: HashMap2

Simple way to store an HashMap[K1, HashMap[K2, V]]
class HashMap3[K1: nullable Object, K2: nullable Object, K3: nullable Object, V: nullable Object]

more_collections :: HashMap3

Simple way to store an HashMap[K1, HashMap[K2, HashMap[K3, V]]]
class HashMap4[K1: nullable Object, K2: nullable Object, K3: nullable Object, K4: nullable Object, V: nullable Object]

more_collections :: HashMap4

Simple way to store an HashMap[K1, HashMap[K2, HashMap[K3, HashMap[K4, V]]]]
class MultiHashMap[K: nullable Object, V: nullable Object]

more_collections :: MultiHashMap

Simple way to store an HashMap[K, Array[V]]
private class UnrolledIterator[E: nullable Object]

more_collections :: UnrolledIterator

class UnrolledList[E: nullable Object]

more_collections :: UnrolledList

An unrolled linked list
private class UnrolledNode[E: nullable Object]

more_collections :: UnrolledNode

Node composing an UnrolledList

Redefined classes

redef abstract class Deserializer

more_collections :: more_collections $ Deserializer

Abstract deserialization service

All class definitions

class BestDistance[E: nullable Object]

more_collections $ BestDistance

Keep track of the best elements according to a distance value.
class DefaultMap[K: nullable Object, V: nullable Object]

more_collections $ DefaultMap

A map with a default value.
redef abstract class Deserializer

more_collections :: more_collections $ Deserializer

Abstract deserialization service
class HashMap2[K1: nullable Object, K2: nullable Object, V: nullable Object]

more_collections $ HashMap2

Simple way to store an HashMap[K1, HashMap[K2, V]]
class HashMap3[K1: nullable Object, K2: nullable Object, K3: nullable Object, V: nullable Object]

more_collections $ HashMap3

Simple way to store an HashMap[K1, HashMap[K2, HashMap[K3, V]]]
class HashMap4[K1: nullable Object, K2: nullable Object, K3: nullable Object, K4: nullable Object, V: nullable Object]

more_collections $ HashMap4

Simple way to store an HashMap[K1, HashMap[K2, HashMap[K3, HashMap[K4, V]]]]
class MultiHashMap[K: nullable Object, V: nullable Object]

more_collections $ MultiHashMap

Simple way to store an HashMap[K, Array[V]]
private class UnrolledIterator[E: nullable Object]

more_collections $ UnrolledIterator

class UnrolledList[E: nullable Object]

more_collections $ UnrolledList

An unrolled linked list
private class UnrolledNode[E: nullable Object]

more_collections $ UnrolledNode

Node composing an UnrolledList
package_diagram more_collections::more_collections more_collections serialization serialization more_collections::more_collections->serialization poset poset more_collections::more_collections->poset serialization->poset meta meta serialization->meta json json serialization->json ...poset ... ...poset->poset ...meta ... ...meta->meta ...json ... ...json->json gamnit::programs programs gamnit::programs->more_collections::more_collections nitcorn::reactor reactor nitcorn::reactor->more_collections::more_collections nitc::toolcontext toolcontext nitc::toolcontext->more_collections::more_collections nitc::mpackage mpackage nitc::mpackage->more_collections::more_collections gamnit::gamnit gamnit gamnit::gamnit->gamnit::programs gamnit::gamnit... ... gamnit::gamnit...->gamnit::gamnit nitcorn::file_server file_server nitcorn::file_server->nitcorn::reactor nitcorn::signal_handler signal_handler nitcorn::signal_handler->nitcorn::reactor nitcorn::log log nitcorn::log->nitcorn::reactor nitcorn::proxy proxy nitcorn::proxy->nitcorn::reactor nitcorn::file_server... ... nitcorn::file_server...->nitcorn::file_server nitcorn::signal_handler... ... nitcorn::signal_handler...->nitcorn::signal_handler nitcorn::log... ... nitcorn::log...->nitcorn::log nitcorn::proxy... ... nitcorn::proxy...->nitcorn::proxy nitc::phase phase nitc::phase->nitc::toolcontext nitc::modelbuilder_base modelbuilder_base nitc::modelbuilder_base->nitc::toolcontext nitc::parser_util parser_util nitc::parser_util->nitc::toolcontext nitc::neo neo nitc::neo->nitc::toolcontext nitc::test_toolcontext test_toolcontext nitc::test_toolcontext->nitc::toolcontext nitc::phase... ... nitc::phase...->nitc::phase nitc::modelbuilder_base... ... nitc::modelbuilder_base...->nitc::modelbuilder_base nitc::parser_util... ... nitc::parser_util...->nitc::parser_util nitc::neo... ... nitc::neo...->nitc::neo nitc::test_toolcontext... ... nitc::test_toolcontext...->nitc::test_toolcontext nitc::mmodule mmodule nitc::mmodule->nitc::mpackage nitc::mmodule... ... nitc::mmodule...->nitc::mmodule

Ancestors

module abstract_collection

core :: abstract_collection

Abstract collection classes and services.
module abstract_text

core :: abstract_text

Abstract class for manipulation of sequences of characters
module array

core :: array

This module introduces the standard array structure.
module bitset

core :: bitset

Services to handle BitSet
module bytes

core :: bytes

Services for byte streams and arrays
module caching

serialization :: caching

Services for caching serialization engines
module circular_array

core :: circular_array

Efficient data structure to access both end of the sequence.
module codec_base

core :: codec_base

Base for codecs to use with streams
module codecs

core :: codecs

Group module for all codec-related manipulations
module collection

core :: collection

This module define several collection classes.
module core

core :: core

Standard classes and methods used by default by Nit programs and libraries.
module engine_tools

serialization :: engine_tools

Advanced services for serialization engines
module environ

core :: environ

Access to the environment variables of the process
module error

core :: error

Standard error-management infrastructure.
module exec

core :: exec

Invocation and management of operating system sub-processes.
module file

core :: file

File manipulations (create, read, write, etc.)
module fixed_ints

core :: fixed_ints

Basic integers of fixed-precision
module fixed_ints_text

core :: fixed_ints_text

Text services to complement fixed_ints
module flat

core :: flat

All the array-based text representations
module gc

core :: gc

Access to the Nit internal garbage collection mechanism
module hash_collection

core :: hash_collection

Introduce HashMap and HashSet.
module inspect

serialization :: inspect

Refine Serializable::inspect to show more useful information
module iso8859_1

core :: iso8859_1

Codec for ISO8859-1 I/O
module kernel

core :: kernel

Most basic classes and methods.
module list

core :: list

This module handle double linked lists
module math

core :: math

Mathematical operations
module meta

meta :: meta

Simple user-defined meta-level to manipulate types of instances as object.
module native

core :: native

Native structures for text and bytes
module numeric

core :: numeric

Advanced services for Numeric types
module protocol

core :: protocol

module queue

core :: queue

Queuing data structures and wrappers
module range

core :: range

Module for range of discrete objects.
module re

core :: re

Regular expression support for all services based on Pattern
module ropes

core :: ropes

Tree-based representation of a String.
module serialization_core

serialization :: serialization_core

Abstract services to serialize Nit objects to different formats
module sorter

core :: sorter

This module contains classes used to compare things and sorts arrays.
module stream

core :: stream

Input and output streams of characters
module text

core :: text

All the classes and methods related to the manipulation of text entities
module time

core :: time

Management of time and dates
module union_find

core :: union_find

union–find algorithm using an efficient disjoint-set data structure
module utf8

core :: utf8

Codec for UTF-8 I/O

Parents

module poset

poset :: poset

Pre order sets and partial order set (ie hierarchies)
module serialization

serialization :: serialization

General serialization services

Children

module mpackage

nitc :: mpackage

Modelisation of a Nit package
module programs

gamnit :: programs

Services for graphical programs with shaders, attributes and uniforms
module reactor

nitcorn :: reactor

Core of the nitcorn project, provides HttpFactory and Action
module toolcontext

nitc :: toolcontext

Common command-line tool infrastructure than handle options and error messages

Descendants

module a_star-m

a_star-m

module abstract_compiler

nitc :: abstract_compiler

Abstract compiler
module actors_generation_phase

nitc :: actors_generation_phase

Generate a support module for each module that contain a class annotated with is actor
module actors_injection_phase

nitc :: actors_injection_phase

Injects model for the classes annotated with "is actor" so
module android

nitc :: android

Compile program for the Android platform
module android19

gamnit :: android19

Variation using features from Android API 19
module android_annotations

nitc :: android_annotations

Additionnal annotations to gather metadata on Android projects
module annotation

nitc :: annotation

Management and utilities on annotations
module api

nitc :: api

Components required to build a web server about the nit model.
module api_auth

nitc :: api_auth

module api_base

nitc :: api_base

Base classes used by nitweb.
module api_docdown

nitc :: api_docdown

Nitdoc specific Markdown format handling for Nitweb
module api_feedback

nitc :: api_feedback

Feedback related features
module api_light

nitc :: api_light

Highlight and collect messages from a piece of code
module api_model

nitc :: api_model

module app_annotations

nitc :: app_annotations

Annotations to gather metadata on app.nit projects
module ast_metrics

nitc :: ast_metrics

Metrics about the nodes and identifiers in the AST
module astbuilder

nitc :: astbuilder

Instantiation and transformation of semantic nodes in the AST of expressions and statements
module auto_super_init

nitc :: auto_super_init

Computing of super-constructors that must be implicitly called at the begin of constructors.
module bmfont

gamnit :: bmfont

Parse Angel Code BMFont format and draw text
module c

nitc :: c

Support for nesting C code within a Nit program using its FFI
module c_compiler_options

nitc :: c_compiler_options

Offers the annotations cflags and ldflags to specify
module camera_control

gamnit :: camera_control

Simple camera control for user, as the method accept_scroll_and_zoom
module camera_control_android

gamnit :: camera_control_android

Two fingers camera manipulation, pinch to zoom and slide to scroll
module camera_control_linux

gamnit :: camera_control_linux

Mouse wheel and middle mouse button to control camera
module cardboard

gamnit :: cardboard

Update the orientation of world_camera at each frame using the head position given by android::cardboard
module catalog

nitc :: catalog

Basic catalog generator for Nit packages
module check_annotation

nitc :: check_annotation

Check that annotation present in the AST are either primitive or user-declared
module code_gen

nitc :: code_gen

Main frontend phases plus code generation phases
module commands_base

nitc :: commands_base

Documentation commands
module commands_catalog

nitc :: commands_catalog

Commands to retrieve Catalog related data
module commands_docdown

nitc :: commands_docdown

Doc down related queries
module commands_graph

nitc :: commands_graph

Graph commands
module commands_http

nitc :: commands_http

Initialize commands from HTTP requests
module commands_model

nitc :: commands_model

Doc commands about a Model or a MEntity
module commands_parser

nitc :: commands_parser

A parser that create DocCommand from a string
module commands_usage

nitc :: commands_usage

Commands about how mentities are used
module compilation

nitc :: compilation

The compilation module of the VirtualMachine
module compiler

nitc :: compiler

Compilation to C
module compiler_ffi

nitc :: compiler_ffi

Full FFI support for the compiler
module compiler_serialization

nitc :: compiler_serialization

Serialization support for the compiler
module contracts

nitc :: contracts

Module to build contract
module cpp

nitc :: cpp

Supports the use of the C++ language through the FFI
module depth

gamnit :: depth

Framework for 3D games in Nit
module depth_core

gamnit :: depth_core

Base entities of the depth 3D game framework
module deriving

nitc :: deriving

Injection of automatic method definitions for standard methods, based on the attributes of the classes
module detect_covariance

nitc :: detect_covariance

Detect the static usage of covariance in the code.
module detect_variance_constraints

nitc :: detect_variance_constraints

Collect metrics about detected variances constraints on formal types.
module div_by_zero

nitc :: div_by_zero

Detection of divisions by zero in obvious cases
module dynamic_loading_ffi

nitc :: dynamic_loading_ffi

Execute FFI code by creating and loading shared libraries
module dynamic_resolution

gamnit :: dynamic_resolution

Virtual screen with a resolution independent from the real screen
module emscripten

nitc :: emscripten

Compile to JavaScript using the Emscripten SDK
module example_angular

popcorn :: example_angular

This is an example of how to use angular.js with popcorn
module explain_assert

nitc :: explain_assert

Explain failed assert to the console by modifying the AST.
module extern_classes

nitc :: extern_classes

Manages all extern classes and their associated foreign type.
module extra_java_files

nitc :: extra_java_files

Intro the annotation extra_java_files to compile extra java files
module ffi

nitc :: ffi

Full FFI support, independent of the compiler
module ffi_base

nitc :: ffi_base

Tools and utilities for implement FFI with different languages
module file_server

nitcorn :: file_server

Provides the FileServer action, which is a standard and minimal file server
module flat

gamnit :: flat

Simple API for 2D games, built around Sprite and App::update
module flat_core

gamnit :: flat_core

Core services for the flat API for 2D games
module flow

nitc :: flow

Intraprocedural static flow.
module font

gamnit :: font

Abstract font drawing services, implemented by bmfont and tileset
module frontend

nitc :: frontend

Collect and orchestration of main frontend phases
module gamnit

gamnit :: gamnit

Game and multimedia framework for Nit
module gamnit_android

gamnit :: gamnit_android

Support services for Gamnit on Android
module gamnit_ios

gamnit :: gamnit_ios

Support services for gamnit on iOS
module gamnit_linux

gamnit :: gamnit_linux

Support services for Gamnit on GNU/Linux
module generate_hierarchies

nitc :: generate_hierarchies

Create dot files for various hierarchies of a model.
module global_compiler

nitc :: global_compiler

Global compilation of a Nit program
module glsl_validation

nitc :: glsl_validation

Check shader code within Nit modules using the tool glslangValidator
module header_dependency

nitc :: header_dependency

Tracks which modules has public header code that must be imported
module highlight

nitc :: highlight

Highlighting of Nit AST
module hooks

github :: hooks

Github hook event listening with nitcorn.
module htcpcp_server

nitcorn :: htcpcp_server

A server that implements HTCPCP. At the moment there are no additions.
module html_commands

nitc :: html_commands

Render commands results as HTML
module html_model

nitc :: html_model

Translate mentities to html blocks.
module htmlight

nitc :: htmlight

Highlighting of Nit AST with HTML
module i18n_phase

nitc :: i18n_phase

Basic support of internationalization through the generation of id-to-string tables
module inheritance_metrics

nitc :: inheritance_metrics

Collect metrics about inheritance usage
module input_ios

gamnit :: input_ios

Gamnit event support for iOS
module interpreter

nitc :: interpreter

Interpretation of Nit programs
module ios

nitc :: ios

Compile programs for the iOS platform
module java

nitc :: java

FFI support for the Java language
module java_compiler

nitc :: java_compiler

Compile Nit code to Java code
module json_commands

nitc :: json_commands

Translate command results to json
module json_model

nitc :: json_model

Make model entities Serializable.
module keys

gamnit :: keys

Simple service keeping track of which keys are currently pressed
module light

nitc :: light

Light FFI support for the compiler
module light_c

nitc :: light_c

Support for nesting C code within a Nit program using its FFI
module light_ffi

nitc :: light_ffi

Light FFI support, independent of the compiler
module light_ffi_base

nitc :: light_ffi_base

Tools and utilities for implement FFI with different languages
module light_only

nitc :: light_only

Compiler support for the light FFI only, detects unsupported usage of callbacks
module limit_fps

gamnit :: limit_fps

Frame-rate control for applications
module literal

nitc :: literal

Parsing of literal values in the abstract syntax tree.
module loader

nitc :: loader

Loading of Nit source files
module loader

github :: loader

module local_var_init

nitc :: local_var_init

Verify that local variables are initialized before their usage
module log

nitcorn :: log

Services inserting a timestamp in all prints and to log each requests
module mclasses_metrics

nitc :: mclasses_metrics

Collect common metrics about mclasses
module md_commands

nitc :: md_commands

Render commands results as Markdown
module memory_logger

nitc :: memory_logger

Extension to inject memory-tracing instrumentation in code generated by nitc.
module mendel_metrics

nitc :: mendel_metrics

The Mendel model helps to understand class hierarchies.
module metrics

nitc :: metrics

Various statistics about Nit models and programs
module metrics_base

nitc :: metrics_base

Helpers for various statistics tools.
module mixin

nitc :: mixin

Loading and additional module refinements at link-time.
module mmodule

nitc :: mmodule

modules and module hierarchies in the metamodel
module mmodule_data

nitc :: mmodule_data

Define and retrieve data in modules
module mmodules_metrics

nitc :: mmodules_metrics

Collect common metrics about modules
module model

nitc :: model

Classes, types and properties
module model_collect

nitc :: model_collect

Collect things from the model.
module model_dimensions

gamnit :: model_dimensions

Dimensions related services for Model and Mesh
module model_examples

nitc :: model_examples

Examples for Model entities
module model_ext

nitc :: model_ext

Extensions to the Nit model for foreign languages.
module model_hyperdoc

nitc :: model_hyperdoc

Dump of Nit model into hypertext human-readable format.
module model_index

nitc :: model_index

Search things from the Model
module model_visitor

nitc :: model_visitor

Simple visitor framework for Nit models.
module model_viz

nitc :: model_viz

Visualisation of Nit models
module modelbuilder_base

nitc :: modelbuilder_base

Load nit source files and build the associated model
module modelize

nitc :: modelize

Create a model from nit source files
module modelize_class

nitc :: modelize_class

Analysis and verification of class definitions to instantiate model element
module modelize_property

nitc :: modelize_property

Analysis and verification of property definitions to instantiate model element
module more_lights

gamnit :: more_lights

More implementations of Light
module more_materials

gamnit :: more_materials

Various material implementations
module more_meshes

gamnit :: more_meshes

More simple geometric meshes
module more_models

gamnit :: more_models

Services to load models from the assets folder
module naive_interpreter

nitc :: naive_interpreter

Interpretation of a Nit program directly on the AST
module neo

nitc :: neo

Save and load a Model to/from a Neo4j graph.
module nit

nitc :: nit

A naive Nit interpreter
module nitc

nitc :: nitc

A Nit compiler
module nitcatalog

nitc :: nitcatalog

Basic catalog generator for Nit packages
module nitcorn

nitcorn :: nitcorn

The nitcorn Web server framework creates server-side Web apps in Nit
module nitcorn_hello_world

nitcorn :: nitcorn_hello_world

Hello World Web server example
module nitcorn_reverse_proxy

nitcorn :: nitcorn_reverse_proxy

Minimal example using a ProxyAction
module nitdoc

nitc :: nitdoc

Generator of static API documentation for the Nit language
module nith

nitc :: nith

A ligHt Nit compiler
module nitj

nitc :: nitj

Compile Nit into Java code runnable on the Java Virtual Machine.
module nitlight

nitc :: nitlight

Tool that produces highlighting for Nit programs
module nitls

nitc :: nitls

Simple tool to list Nit source files
module nitmetrics

nitc :: nitmetrics

A program that collects various metrics on nit programs and libraries
module nitni

nitc :: nitni

Native interface related services (used underneath the FFI)
module nitni_base

nitc :: nitni_base

Native interface related services (used underneath the FFI)
module nitni_callbacks

nitc :: nitni_callbacks

nitni services related to callbacks (used underneath the FFI)
module nitpackage

nitc :: nitpackage

Helpful features about packages
module nitpick

nitc :: nitpick

A program that collect potential style and code issues
module nitpretty

nitc :: nitpretty

module nitrestful

nitc :: nitrestful

Tool generating boilerplate code linking RESTful actions to Nit methods
module nitsaf

nitc :: nitsaf

Nit Static Analysis Framework client example.
module nitserial

nitc :: nitserial

Serialization support compiler, a tool to support deserialization of live generic types
module nitsmells

nitc :: nitsmells

module nituml

nitc :: nituml

UML generator in dot format.
module nitunit

nitc :: nitunit

Testing tool.
module nitvm

nitc :: nitvm

The Nit virtual machine launcher
module nitweb

nitc :: nitweb

Runs a webserver based on nitcorn that render things from model.
module nitx

nitc :: nitx

nitx, a command tool that displays useful data about Nit code
module no_warning

nitc :: no_warning

Fill toolcontext information about blacklisting of warnings.
module nullables_metrics

nitc :: nullables_metrics

Statistics about the usage of nullables
module objc

nitc :: objc

FFI support for Objective-C
module on_demand_compiler

nitc :: on_demand_compiler

Compiles extern code within a module to a static library, as needed
module parallelization_phase

nitc :: parallelization_phase

Phase generating threads for functions annotated with threaded annotation
module parse_annotations

nitc :: parse_annotations

Simple annotation parsing
module parser_util

nitc :: parser_util

Utils and tools related to parsers and AST
module particles

gamnit :: particles

Particle effects
module phase

nitc :: phase

Phases of the processing of nit programs
module pkgconfig

nitc :: pkgconfig

Offers the PkgconfigPhase to use the external program "pkg-config" in order
module platform

nitc :: platform

Platform system, used to customize the behavior of the compiler.
module pop_auth

popcorn :: pop_auth

Authentification handlers.
module pop_handlers

popcorn :: pop_handlers

Route handlers.
module pop_json

popcorn :: pop_json

Introduce useful services for JSON REST API handlers.
module pop_routes

popcorn :: pop_routes

Internal routes representation.
module pop_sessions

popcorn :: pop_sessions

Session handlers
module pop_tasks

popcorn :: pop_tasks

Popcorn threaded tasks
module pop_templates

popcorn :: pop_templates

Template rendering for popcorn
module pop_tests

popcorn :: pop_tests

Popcorn testing services
module popcorn

popcorn :: popcorn

Application server abstraction on top of nitcorn.
module poset_metrics

nitc :: poset_metrics

Metrics about the various posets of the model of a Nit program
module pretty

nitc :: pretty

Library used to pretty print Nit code.
module proxy

nitcorn :: proxy

Provides the ProxyAction action, which redirects requests to another interface
module pthreads

nitcorn :: pthreads

Activate the use of pthreads with nitcorn
module rapid_type_analysis

nitc :: rapid_type_analysis

Rapid type analysis on the AST
module readme_metrics

nitc :: readme_metrics

Collect common metrics about README files
module refinement_metrics

nitc :: refinement_metrics

Collect metrics about refinement usage
module regex_phase

nitc :: regex_phase

Check for error in regular expressions from string literals
module restful

nitcorn :: restful

Support module for the nitrestful tool and the restful annotation
module restful_annot

nitcorn :: restful_annot

Example for the restful annotation documented at lib/nitcorn/restful.nit
module rta_metrics

nitc :: rta_metrics

Metrics from RTA
module saf

nitc :: saf

Nit Static Analysis Framework.
module saf_base

nitc :: saf_base

Static Analysis Framework base
module scope

nitc :: scope

Identification and scoping of local variables and labels.
module selection

gamnit :: selection

Select Actor from a screen coordinate
module self_metrics

nitc :: self_metrics

Metrics about the usage of explicit and implicit self
module semantize

nitc :: semantize

Process bodies of methods in regard with the model.
module sensors

android :: sensors

Access Android sensors
module separate_compiler

nitc :: separate_compiler

Separate compilation of a Nit program
module separate_erasure_compiler

nitc :: separate_erasure_compiler

Separate compilation of a Nit program with generic type erasure
module serialization_code_gen_phase

nitc :: serialization_code_gen_phase

Phase generating methods (code) to serialize Nit objects
module serialization_model_phase

nitc :: serialization_model_phase

Phase generating methods (model-only) to serialize Nit objects
module serialize_model

nitc :: serialize_model

Service to serialize POSet to JSON
module shadow

gamnit :: shadow

Shadow mapping using a depth texture
module signal_handler

nitcorn :: signal_handler

Handle SIGINT and SIGTERM to close the server after all active events
module simple_file_server

nitcorn :: simple_file_server

Basic file server on port 80 by default, may require root to execute
module simple_misc_analysis

nitc :: simple_misc_analysis

Simple vavious processing on a AST
module ssa

nitc :: ssa

Single-Static Assignment algorithm from an AST
module static

nitc :: static

Nitdoc generation framework
module static_base

nitc :: static_base

Base entities shared by all the nitdoc code
module static_cards

nitc :: static_cards

Cards templates for the static documentation
module static_html

nitc :: static_html

Render documentation pages as HTML
module static_index

nitc :: static_index

Manage indexing of Nit model for Nitdoc QuickSearch.
module static_structure

nitc :: static_structure

Composes the pages of the static documentation
module static_types_metrics

nitc :: static_types_metrics

Metrics on the usage of explicit static types.
module stereoscopic_view

gamnit :: stereoscopic_view

Refine EulerCamera and App::frame_core_draw to get a stereoscopic view
module tables_metrics

nitc :: tables_metrics

Metrics on table generation
module term

nitc :: term

module term_model

nitc :: term_model

Markdown templates for Nit model MEntities.
module test_astbuilder

nitc :: test_astbuilder

Program used to test the clone method of the astbuilder tool
module test_highlight

nitc :: test_highlight

Program used to test the Nit highlighter
module test_model_visitor

nitc :: test_model_visitor

Example of model_visitor
module test_neo

nitc :: test_neo

Test for neo model saving and loading.
module test_parser

nitc :: test_parser

Program used to test the NIT parser
module test_phase

nitc :: test_phase

Stub for loading a runing phases on a bunch of modules
module test_test_phase

nitc :: test_test_phase

Example of simple module that aims to do some specific work on nit programs.
module test_toolcontext

nitc :: test_toolcontext

Program used to test ToolContext
module testing

nitc :: testing

Test unit generation and execution for Nit.
module testing_base

nitc :: testing_base

Base options for testing tools.
module testing_doc

nitc :: testing_doc

Testing from code comments.
module testing_gen

nitc :: testing_gen

Test Suites generation.
module testing_suite

nitc :: testing_suite

Testing from external files.
module tileset

gamnit :: tileset

Support for TileSet, TileSetFont and drawing text with TextSprites
module transform

nitc :: transform

Thansformations that simplify the AST of expressions
module typing

nitc :: typing

Intraprocedural resolution of static types and OO-services
module uml

nitc :: uml

Group head module for UML generation services
module uml_base

nitc :: uml_base

Exposes the base class for UML generation of a Model
module uml_class

nitc :: uml_class

Provides facilities of exporting a Model to a UML class diagram
module uml_module

nitc :: uml_module

Services for generation of a UML package diagram based on a Model
module variables_numbering

nitc :: variables_numbering

Handle all numbering operations related to local variables in the Nit virtual machine
module vim_autocomplete

nitc :: vim_autocomplete

Generate files used by the Vim plugin to autocomplete with doc
module virtual_gamepad

gamnit :: virtual_gamepad

Virtual gamepad mapped to keyboard keys for quick and dirty mobile support
module virtual_machine

nitc :: virtual_machine

Implementation of the Nit virtual machine
module vm

nitc :: vm

Entry point of all vm components
module vm_optimizations

nitc :: vm_optimizations

Optimization of the nitvm
module vr

gamnit :: vr

VR support for gamnit depth, for Android only
module xcode_templates

nitc :: xcode_templates

Templates and other services to create XCode projects
# Highly specific, but useful, collections-related classes.
module more_collections is serialize

import serialization
import poset

# Simple way to store an `HashMap[K, Array[V]]`
#
# Unlike standard HashMap, MultiHashMap provides a new
# empty array on the first access on a unknown key.
#
#     var m = new MultiHashMap[String, Char]
#     assert not m.has_key("four")
#     m["four"].add('i')
#     m["four"].add('i')
#     m["four"].add('i')
#     m["four"].add('i')
#     assert m.has_key("four")
#     assert m["four"] == ['i', 'i', 'i', 'i']
#     assert m["zzz"] == new Array[Char]
class MultiHashMap[K, V]
	super HashMap[K, Array[V]]

	# Add `v` to the array associated with `k`.
	#
	# If there is no array associated, then create it.
	#
	# For the inverse operation, see `remove_one`.
	#
	# ```
	# var m = new MultiHashMap[String, Char]
	# m.add_one("four", 'i')
	# m.add_one("four", 'i')
	# m.add_one("four", 'i')
	# m.add_one("four", 'i')
	# assert m.has_key("four")
	# assert m["four"] == ['i', 'i', 'i', 'i']
	# ```
	fun add_one(k: K, v: V)
	do
		var x = self.get_or_null(k)
		if x != null then
			x.add(v)
		else
			self[k] = [v]
		end
	end

	redef fun provide_default_value(key) do
		var res = new Array[V]
		self[key] = res
		return res
	end

	# Remove an occurrence of `v` from the array associated with `k`.
	#
	# If the associated array does not contain `v`, do nothing. If the
	# associated array only contain one element and this element is `v`, remove
	# the key `k`.
	#
	# In a nutshell, does the inverse operation of `add_one`.
	#
	# ```
	# var m = new MultiHashMap[String, Char]
	# m["four"]        =  ['4', 'i', 'i', 'i', 'i']
	# m.remove_one("four", 'i')
	# assert m["four"] == ['4', 'i', 'i', 'i']
	#
	# m = new MultiHashMap[String, Char]
	# m.add_one("one", '1')
	# m.remove_one("one", '?')
	# assert m["one"] == ['1']
	# m.remove_one("one", '1')
	# assert not m.has_key("one")
	# assert m["one"] == new Array[Char]
	#
	# m = new MultiHashMap[String, Char]
	# m.add_one("one", '1')
	# m.remove_one("two", '2')
	# assert not m.has_key("two")
	# assert m["one"] == ['1']
	# assert m["two"] == new Array[Char]
	# ```
	fun remove_one(k: K, v: V)
	do
		var x = get_or_null(k)
		if x != null then
			x.remove(v)
			if x.is_empty then keys.remove(k)
		end
	end

	# Search the values in `pe.greaters` from the most smaller elements that have a value.
	#
	# Elements without values are ignored.
	#
	# Basically, values defined in nearest greater elements of `pe` are inherited.
	#
	# ~~~
	# var pos = new POSet[String]
	# pos.add_chain(["E", "D", "C", "B", "A"])
	# pos.add_chain(["D", "X", "B"])
	#
	# var map = new MultiHashMap[String, String]
	# map["A"].append(["a", "1"])
	# map["C"].append(["c", "2"])
	# map["X"].append(["x", "2"])
	# map["E"].add "e"
	#
	# assert map.lookup_joined_values(pos["B"]).has_exactly(["a", "1"])
	# assert map.lookup_joined_values(pos["C"]).has_exactly(["c", "2"])
	# assert map.lookup_joined_values(pos["D"]).has_exactly(["c", "x", "2"])
	# ~~~
	fun lookup_joined_values(pe: POSetElement[K]): Set[V]
	do
		var res = new Set[V]
		for k in pe.poset.select_smallest(filter_keys(pe.greaters)) do res.add_all self[k]
		return res

	end
end

# Simple way to store an `HashMap[K1, HashMap[K2, V]]`
#
# ~~~~
# var hm2 = new HashMap2[Int, String, Float]
# hm2[1, "one"] = 1.0
# hm2[2, "two"] = 2.0
# assert hm2[1, "one"] == 1.0
# assert hm2[2, "not-two"] == null
# ~~~~
class HashMap2[K1, K2, V]

	private var level1 = new HashMap[K1, HashMap[K2, V]]

	# Return the value associated to the keys `k1` and `k2`.
	# Return `null` if no such a value.
	fun [](k1: K1, k2: K2): nullable V
	do
		var level1 = self.level1
		var level2 = level1.get_or_null(k1)
		if level2 == null then return null
		return level2.get_or_null(k2)
	end

	# Set `v` the value associated to the keys `k1` and `k2`.
	fun []=(k1: K1, k2: K2, v: V)
	do
		var level1 = self.level1
		var level2 = level1.get_or_null(k1)
		if level2 == null then
			level2 = new HashMap[K2, V]
			level1[k1] = level2
		end
		level2[k2] = v
	end

	# Remove the item at `k1` and `k2`
	fun remove_at(k1: K1, k2: K2)
	do
		var level1 = self.level1
		var level2 = level1.get_or_null(k1)
		if level2 == null then return
		level2.keys.remove(k2)
	end

	# Is there a value at `k1, k2`?
	fun has(k1: K1, k2: K2): Bool
	do
		if not level1.keys.has(k1) then return false
		return level1[k1].keys.has(k2)
	end

	# Remove all items
	fun clear do level1.clear
end

# Simple way to store an `HashMap[K1, HashMap[K2, HashMap[K3, V]]]`
#
# ~~~~
# var hm3 = new HashMap3[Int, String, Int, Float]
# hm3[1, "one", 11] = 1.0
# hm3[2, "two", 22] = 2.0
# assert hm3[1, "one", 11] == 1.0
# assert hm3[2, "not-two", 22] == null
# ~~~~
class HashMap3[K1, K2, K3, V]

	private var level1 = new HashMap[K1, HashMap2[K2, K3, V]]

	# Return the value associated to the keys `k1`, `k2`, and `k3`.
	# Return `null` if no such a value.
	fun [](k1: K1, k2: K2, k3: K3): nullable V
	do
		var level1 = self.level1
		var level2 = level1.get_or_null(k1)
		if level2 == null then return null
		return level2[k2, k3]
	end

	# Set `v` the value associated to the keys `k1`, `k2`, and `k3`.
	fun []=(k1: K1, k2: K2, k3: K3, v: V)
	do
		var level1 = self.level1
		var level2 = level1.get_or_null(k1)
		if level2 == null then
			level2 = new HashMap2[K2, K3, V]
			level1[k1] = level2
		end
		level2[k2, k3] = v
	end

	# Remove the item at `k1`, `k2` and `k3`
	fun remove_at(k1: K1, k2: K2, k3: K3)
	do
		var level1 = self.level1
		var level2 = level1.get_or_null(k1)
		if level2 == null then return
		level2.remove_at(k2, k3)
	end

	# Is there a value at `k1, k2, k3`?
	fun has(k1: K1, k2: K2, k3: K3): Bool
	do
		if not level1.keys.has(k1) then return false
		return level1[k1].has(k2, k3)
	end

	# Remove all items
	fun clear do level1.clear
end

# Simple way to store an `HashMap[K1, HashMap[K2, HashMap[K3, HashMap[K4, V]]]]`
#
# ~~~~
# var hm4 = new HashMap4[Int, String, Int, String, Float]
# hm4[1, "one", 11, "un"] = 1.0
# hm4[2, "two", 22, "deux"] = 2.0
# assert hm4[1, "one", 11, "un"] == 1.0
# assert hm4[2, "not-two", 22, "deux"] == null
# ~~~~
class HashMap4[K1, K2, K3, K4, V]

	private var level1 = new HashMap[K1, HashMap3[K2, K3, K4, V]]

	# Return the value associated to the keys `k1`, `k2`, `k3` and `k4`.
	# Return `null` if no such a value.
	fun [](k1: K1, k2: K2, k3: K3, k4: K4): nullable V
	do
		var level1 = self.level1
		var level2 = level1.get_or_null(k1)
		if level2 == null then return null
		return level2[k2, k3, k4]
	end

	# Set `v` the value associated to the keys `k1`, `k2`, `k3` and `k4`.
	fun []=(k1: K1, k2: K2, k3: K3, k4: K4, v: V)
	do
		var level1 = self.level1
		var level2 = level1.get_or_null(k1)
		if level2 == null then
			level2 = new HashMap3[K2, K3, K4, V]
			level1[k1] = level2
		end
		level2[k2, k3, k4] = v
	end

	# Remove the item at `k1`, `k2`, `k3` and `k4`
	fun remove_at(k1: K1, k2: K2, k3: K3, k4: K4)
	do
		var level1 = self.level1
		var level2 = level1.get_or_null(k1)
		if level2 == null then return
		level2.remove_at(k2, k3, k4)
	end

	# Is there a value at `k1, k2, k3, k4`?
	fun has(k1: K1, k2: K2, k3: K3, k4: K4): Bool
	do
		if not level1.keys.has(k1) then return false
		return level1[k1].has(k2, k3, k4)
	end

	# Remove all items
	fun clear do level1.clear
end

# A map with a default value.
#
# ~~~~
# var dm = new DefaultMap[String, Int](10)
# assert dm["a"] == 10
# ~~~~
#
# The default value is used when the key is not present.
# And getting a default value does not register the key.
#
# ~~~~
# assert dm["a"] == 10
# assert dm.length == 0
# assert dm.has_key("a") == false
# ~~~~
#
# It also means that removed key retrieve the default value.
#
# ~~~~
# dm["a"] = 2
# assert dm["a"] == 2
# dm.keys.remove("a")
# assert dm["a"] == 10
# ~~~~
#
# Warning: the default value is used as is, so using mutable object might
# cause side-effects.
#
# ~~~~
# var dma = new DefaultMap[String, Array[Int]](new Array[Int])
#
# dma["a"].add(65)
# assert dma["a"] == [65]
# assert dma.default == [65]
# assert dma["c"] == [65]
#
# dma["b"] += [66]
# assert dma["b"] == [65, 66]
# assert dma.default == [65]
# ~~~~
class DefaultMap[K, V]
	super HashMap[K, V]

	# The default value.
	var default: V

	redef fun provide_default_value(key) do return default
end

# An unrolled linked list
#
# A sequence implemented as a linked list of arrays.
#
# This data structure is similar to the `List` but it can benefit from
# better cache performance, lower data overhead for the nodes metadata and
# it spares the GC to allocate many small nodes.
class UnrolledList[E]
	super Sequence[E]

	# Desired capacity for each nodes
	#
	# By default at `32`, it can be increased for very large lists.
	#
	# It can be modified anytime, but newly created nodes may still be assigned
	# the same capacity of old nodes when created by `insert`.
	var nodes_length = 32 is writable

	private var head_node: UnrolledNode[E] = new UnrolledNode[E](nodes_length)

	private var tail_node: UnrolledNode[E] = head_node

	redef var length = 0

	redef fun clear
	do
		head_node = new UnrolledNode[E](nodes_length)
		tail_node = head_node
		length = 0
	end

	# Out parameter of `node_at`
	private var index_within_node = 0

	private fun node_at(index: Int): UnrolledNode[E]
	do
		assert index >= 0 and index < length

		var node = head_node
		while index >= node.length do
			index -= node.length
			node = node.next.as(not null)
		end

		index_within_node = index
		return node
	end

	private fun insert_node(node: UnrolledNode[E], prev, next: nullable UnrolledNode[E])
	do
		if prev != null then
			prev.next = node
		else head_node = node

		if next != null then
			next.prev = node
		else tail_node = node

		node.next = next
		node.prev = prev
	end

	redef fun [](index)
	do
		var node = node_at(index)
		index = index_within_node + node.head_index
		return node.items[index]
	end

	redef fun []=(index, value)
	do
		var node = node_at(index)
		index = index_within_node + node.head_index
		node.items[index] = value
	end

	redef fun push(item)
	do
		var node = tail_node
		if not node.full then
			if node.tail_index < node.capacity then
				# There's room at the tail
				node.tail_index += 1
			else
				# Move everything over by `d`
				assert node.head_index > 0
				var d = node.head_index / 2 + 1
				node.move_head(node.length, d)
				for i in d.times do node.items[node.tail_index - i] = null
				node.head_index -= d
				node.tail_index += -d+1
			end
			node.items[node.tail_index-1] = item
		else
			# New node!
			node = new UnrolledNode[E](nodes_length)
			insert_node(node, tail_node, null)
			node.tail_index = 1
			node.items[0] = item
		end
		length += 1
	end

	redef fun unshift(item)
	do
		var node = head_node
		if not node.full then
			if node.head_index > 0 then
				# There's room at the head
				node.head_index -= 1
			else
				# Move everything over by `d`
				assert node.tail_index < node.capacity
				var d = (node.capacity-node.tail_index) / 2 + 1
				node.move_tail(0, d)
				for i in d.times do node.items[node.head_index+i] = null
				node.head_index += d-1
				node.tail_index += d
			end
			node.items[node.head_index] = item
		else
			# New node!
			node = new UnrolledNode[E](nodes_length)
			insert_node(node, null, head_node)
			node.head_index = node.capacity-1
			node.tail_index = node.capacity
			node.items[node.capacity-1] = item
		end
		length += 1
	end

	redef fun pop
	do
		assert not_empty

		var node = tail_node
		while node.length == 0 do
			# Delete empty node
			var nullable_node = node.prev
			assert is_not_empty: nullable_node != null
			node = nullable_node
			node.next = null
			self.tail_node = node
		end

		var item = node.items[node.tail_index-1]
		node.tail_index -= 1
		length -= 1
		return item
	end

	redef fun shift
	do
		assert not_empty

		var node = head_node
		while node.length == 0 do
			# Delete empty node
			var nullable_node = node.next
			assert is_not_empty: nullable_node != null
			node = nullable_node
			node.prev = null
			self.head_node = node
		end

		var item = node.items[node.head_index]
		node.head_index += 1
		length -= 1
		return item
	end

	redef fun insert(item, index)
	do
		if index == length then
			push item
			return
		end

		var node = node_at(index)
		index = index_within_node
		if node.full then
			# Move half to a new node
			var new_node = new UnrolledNode[E](nodes_length.max(node.capacity))

			# Plug in the new node
			var next_node = node.next
			insert_node(new_node, node, next_node)

			# Move items at and after `index` to the new node
			var to_displace = node.length-index
			var offset = (new_node.capacity-to_displace)/2
			for i in [0..to_displace[ do
				new_node.items[offset+i] = node.items[index+i]
				node.items[index+i] = null
			end
			new_node.head_index = offset
			new_node.tail_index = offset + to_displace
			node.tail_index -= to_displace

			# Store `item`
			if index > node.capacity / 2 then
				new_node.items[offset-1] = item
				new_node.head_index -= 1
			else
				node.items[node.head_index+index] = item
				node.tail_index += 1
			end
		else
			if node.tail_index < node.capacity then
				# Move items towards the tail
				node.move_tail(index, 1)
				node.tail_index += 1
				node.items[node.head_index + index] = item
			else
				# Move items towards the head
				node.move_head(index, 1)
				node.items[node.head_index + index-1] = item
				node.head_index -= 1
			end
		end
		length += 1
	end

	redef fun remove_at(index)
	do
		var node = node_at(index)
		index = index_within_node + node.head_index

		# Shift left all the elements after `index`
		for i in [index+1 .. node.tail_index[ do
			node.items[i-1] = node.items[i]
		end
		node.tail_index -= 1
		node.items[node.tail_index] = null

		length -= 1

		var next_node = node.next
		var prev_node = node.prev
		if node.is_empty and (next_node != null or prev_node != null) then
			# Empty and non-head or tail node, delete
			if next_node != null then
				next_node.prev = node.prev
			else tail_node = prev_node.as(not null)

			if prev_node != null then
				prev_node.next = node.next
			else head_node = next_node.as(not null)
		end
	end

	redef fun iterator do return new UnrolledIterator[E](self)
end

# Node composing an `UnrolledList`
#
# Stores the elements in the `items` array. The elements in the `items` array
# begin at `head_index` and end right before `tail_index`. The data is contiguous,
# but there can be empty cells at the beginning and the end of the array.
private class UnrolledNode[E]

	var prev: nullable UnrolledNode[E] = null

	var next: nullable UnrolledNode[E] = null

	# Desired length of `items`
	var capacity: Int

	# `Array` of items in this node, filled with `null`
	var items = new Array[nullable E].filled_with(null, capacity) is lazy

	# Index of the first element in `items`
	var head_index = 0

	# Index after the last element in `items`
	var tail_index = 0

	fun length: Int do return tail_index - head_index

	fun full: Bool do return length == capacity

	fun is_empty: Bool do return tail_index == head_index

	# Move towards the head all elements before `index` of `displace` cells
	fun move_tail(index, displace: Int)
	do
		for i in [tail_index-1..head_index+index].step(-1) do
			items[i+displace] = items[i]
		end
	end

	# Move towards the tail all elements at and after `index` of `displace` cells
	fun move_head(index, displace: Int)
	do
		for i in [head_index..head_index+index[ do
			items[i-displace] = items[i]
		end
	end
end

private class UnrolledIterator[E]
	super IndexedIterator[E]

	var list: UnrolledList[E]

	var node: nullable UnrolledNode[E] = list.head_node is lazy

	# Index of the current `item`
	redef var index = 0

	# Index within the current `node`
	var index_in_node: Int = node.head_index is lazy

	redef fun item do return node.items[index_in_node]

	redef fun is_ok do return index < list.length

	redef fun next
	do
		index += 1
		index_in_node += 1

		if index_in_node >= node.tail_index then
			node = node.next
			if node != null then index_in_node = node.head_index
		end
	end
end

# Keep track of the best elements according to a distance value.
#
# ~~~
# var bests = new BestDistance[String](5)
# bests.update(10, "Too big")
# assert bests.best_items.is_empty
# bests.update(5, "Just fine")
# bests.update(5, "Another one")
# assert bests.best_items.has_exactly(["Just fine", "Another one"])
# bests.update(2, "A better one")
# bests.update(4, "Not good enough")
# assert bests.best_distance == 2
# assert bests.best_items.has_exactly(["A better one"])
# ~~~
class BestDistance[E]
	# Current smallest distance
	var best_distance: Int is writable

	# Known elements with the smallest distance
	var best_items = new Set[E] is writable

	# Register a `candidate` with a `distance`
	#
	# * To high, it is ignored.
	# * Equal to the current best, it is added
	# * Better that them, is is the new best element
	#
	# Return `true` if the candidate is kept (alone or with other)
	# returns `false` if the candidate is ignored.
	fun update(distance: Int, candidate: E): Bool
	do
		if distance > best_distance then return false
		if distance < best_distance then
			best_distance = distance
			best_items.clear
		end
		best_items.add candidate
		return true
	end
end

lib/more_collections/more_collections.nit:15,1--719,3