mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-17 00:24:16 +00:00
better CSS; better docs for teh tables module
This commit is contained in:
@@ -227,7 +227,6 @@ body {
|
||||
padding-top: 10%; }
|
||||
|
||||
p.module-desc {
|
||||
font-style: italic;
|
||||
font-size: 1.1em;
|
||||
color: #666666; }
|
||||
|
||||
@@ -559,7 +558,8 @@ pre {
|
||||
.pre {
|
||||
font-family: "Source Code Pro", Monaco, Menlo, Consolas, "Courier New", monospace;
|
||||
font-weight: 600;
|
||||
color: #504da6; }
|
||||
/*color: #504da6;*/
|
||||
}
|
||||
|
||||
code {
|
||||
padding: 2px 4px;
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
#
|
||||
#
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2013 Andreas Rumpf
|
||||
# (c) Copyright 2014 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## The ``tables`` module implements an efficient hash table that is
|
||||
## a mapping from keys to values.
|
||||
## The ``tables`` module implements variants of an efficient hash table that is
|
||||
## a mapping from keys to values. ``Table`` is the usual hash table,
|
||||
## ``OrderedTable`` is like ``Table`` but remembers insertion order
|
||||
## and ``CountTable`` is a mapping from a key to its number of occurances.
|
||||
## For consistency with every other data type in Nim these have **value**
|
||||
## semantics, this means that ``=`` performs a copy of the hash table.
|
||||
## For **reference** semantics use the ``Ref`` variant: ``TableRef``,
|
||||
## ``OrderedTableRef``, ``CountTableRef``.
|
||||
##
|
||||
## If you are using simple standard types like ``int`` or ``string`` for the
|
||||
## keys of the table you won't have any problems, but as soon as you try to use
|
||||
@@ -24,9 +30,15 @@
|
||||
##
|
||||
## What is happening here is that the types used for table keys require to have
|
||||
## a ``hash()`` proc which will convert them to a `THash <hashes.html#THash>`_
|
||||
## value, and the compiler is listing all the hash functions it knows. After
|
||||
## you add such a proc for your custom type everything will work. See this
|
||||
## example:
|
||||
## value, and the compiler is listing all the hash functions it knows.
|
||||
## Additionally there has to be a ``==`` operator that provides the same
|
||||
## semantics as its corresponding ``hash`` proc.
|
||||
##
|
||||
## After you add ``hash`` and ``==`` for your custom type everything will work.
|
||||
## Currently however ``hash`` for objects is not defined, whereas
|
||||
## ``system.==`` for objects does exist and performs a "deep" comparison (every
|
||||
## field is compared) which is usually what you want. So in the following
|
||||
## example implementing only ``hash`` suffices:
|
||||
##
|
||||
## .. code-block::
|
||||
## type
|
||||
@@ -51,9 +63,6 @@
|
||||
## p2.firstName = "소진"
|
||||
## p2.lastName = "박"
|
||||
## salaries[p2] = 45_000
|
||||
##
|
||||
## **Note:** The data types declared here have *value semantics*: This means
|
||||
## that ``=`` performs a copy of the hash table.
|
||||
|
||||
import
|
||||
hashes, math
|
||||
|
||||
2
todo.txt
2
todo.txt
@@ -1,8 +1,6 @@
|
||||
version 0.10
|
||||
============
|
||||
|
||||
- document the tables module better
|
||||
|
||||
- The bitwise 'not' operator will be renamed to 'bnot' to
|
||||
prevent 'not 4 == 5' from compiling. -> requires 'mixin' annotation for procs!
|
||||
- A named tuple will be compatible to a tuple with different names.
|
||||
|
||||
Reference in New Issue
Block a user