< Erlang (programming language) | TutorialsRevision as of 07:07, 8 August 2009 by imported>Tom Morris
The metadata subpage is missing. You can start it via filling in this form or by following the instructions that come up after clicking on the [show] link to the right.
|
Do you see this on PREVIEW? then SAVE! before following a link.
A - For a New Cluster use the following directions
Subpages format requires a metadata page.
Using the following instructions will complete the process of creating this article's subpages.
- Click the blue "metadata template" link below to create the page.
- On the edit page that appears paste in the article's title across from "
pagename = ".
- You might also fill out the checklist part of the form. Ignore the rest.
- For background, see Using the Subpages template Don't worry--you'll get the hang of it right away.
- Remember to hit Save!
the "metadata template".
However, you can create articles without subpages. Just delete the {{subpages}} template from the top of this page and this prompt will disappear. :) Don't feel obligated to use subpages, it's more important that you write sentences, which you can always do without writing fancy code.
|
B - For a Cluster Move use the following directions
The metadata template should be moved to the new name as the first step. Please revert this move and start by using the Move Cluster link at the top left of the talk page.
The name prior to this move can be found at the following link.
|
|
gb_sets
Why go to the bother of using a structure other than a list for sets?
Normally for small sets, lists work fine. But operations on lists
are slow, and awkward if the list is long. Long depends on the machine
and available memory. Generally speaking, a balanced binary tree
will give the fastest access time of most any alternative data structure.
Generally the speed is O(log(n)) for a binary tree. Whereas a list is
order O(n).
Using gb_sets
Lets create a genalized balanced set from a list.
1> A = gb_sets:from_list([1,2,3,4,5]).
{5,{3,{2,{1,nil,nil},nil},{5,{4,nil,nil},nil}}}
3
/ \
2 5
/ / \
1 4
Now we remove an element.
2> B = gb_sets:del_element(1,A).
{4,{3,{2,nil,nil},{5,{4,nil,nil},nil}}}
3
/ \
2 5
/ \
4
And remove another element.
4> C = gb_sets:del_element(2,B).
{3,{3,nil,{5,{4,nil,nil},nil}}}
3
/ \
5
/ \
4
Now we should balance the tree to keep our speed maximized.
5> D = gb_sets:balance(C).
{3,{4,{3,nil,nil},{5,nil,nil}}}
4
/ \
3 5