-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocs.json
More file actions
169 lines (169 loc) · 11.1 KB
/
docs.json
File metadata and controls
169 lines (169 loc) · 11.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
[
{
"kind": "module",
"file": "source\\elembuf.d",
"members": [
{
"parameters": [
{
"kind": "type",
"name": "A"
}
],
"line": 192,
"kind": "template",
"char": 6,
"members": [
{
"storageClass": [
"auto"
],
"parameters": [
{
"type": "A",
"name": "arg"
}
],
"line": 192,
"kind": "function",
"char": 6,
"name": "buffer",
"type": "(A arg)",
"endchar": 1,
"endline": 198
}
],
"name": "buffer",
"comment": " $(P Dynamic circular array.)\n\n $(BR) $(BR)\n\n <a href=\"https://cyroxin.github.io/Elembuf/elembuf.html\"><<\/a>\n\n\n$(P $(BIG Takes an advantage of the system's memory mirroring capabillities to\n create a memory loop so that memory copying wont be necessary once new data is concatenated.\n The buffer may be manipulated normally as if it were a T[] and can be implicitly converted to it.\n Buffer length after concatenation must be less or equal to the `.max` size of the array. ))\n\n $(BR)\n\nParams:\n arg = The initiating data for the array. If it is immutable, it is copied into a mutable buffer. An empty buffer initiation can be achieved with the `.init` of any array type.\n\n Returns:\n `buffer!(Unqual!(ForeachType!A)[], false)`\n\n Examples:\n ---\n auto buf = buffer(\"Hello world!\");\n ---\n ---\n buffer!(char[], false) buf = \"Hello world!\";\n ---\n ---\n buffer!(int[], false) buf = buffer([1,2,3,4,5]);\n ---\n ---\n buffer!(ulong[], false) buf = buffer(cast(ulong[]) [1,2,3,4,5]);\n ---\n\n Bugs:\n $(UL $(LI $(BIG The `~=` -operator cannot be used in `@nogc` code, but it does not use the GC.)))\n"
},
{
"parameters": [
{
"kind": "type",
"name": "A"
}
],
"line": 265,
"kind": "template",
"char": 6,
"members": [
{
"storageClass": [
"auto"
],
"parameters": [
{
"type": "A",
"name": "arg"
}
],
"line": 265,
"kind": "function",
"char": 6,
"name": "tbuffer",
"type": "(A arg)",
"endchar": 1,
"endline": 271
}
],
"name": "tbuffer",
"comment": "$(P Threaded dynamic circular array.)\n\n$(BR) $(BR)\n\n<a href=\"https://cyroxin.github.io/Elembuf/elembuf.html\"><<\/a>\n\n\n$(P $(BIG It is a wait-free single consumer-producer threaded version of the unthreaded circular array. It achieves high throughput as it does not use mutexes or the built-in\n synchronized keyword. It however loses the ability to directly add elements to the buffer, the producer should instead be taught on how to fill the buffer using function pointers &\n delegates.))\n\n $(BR)\n\n Params:\n arg = The initiating data for the array. If it is immutable, it is copied into a mutable buffer. An empty buffer initiation can be achieved with the `.init` of any array type.\n\n Returns:\n `buffer!(Unqual!(ForeachType!A)[], true)`\n\nExamples:\n ---\n auto buf = tbuffer(\"Hello world!\");\n ---\n ---\n buffer!(char[], true) buf = \"Hello world!\";\n ---\n ---\n buffer!(int[], true) buf = tbuffer([1,2,3,4,5]);\n ---\n ---\n buffer!(ulong[], true) buf = tbuffer(cast(ulong[]) [1,2,3,4,5]);\n ---\n\n Bugs:\n $(UL $(LI $(BIG The `~=` -operator cannot be used in `@nogc` code, but it does not use the GC.)))\n\n Note:\n $(P The threaded version of the buffer loses the ability to concat directly to the buffer. Instead you should teach the producer how to fill the buffer: )\n\n ---\n alias T = char;\n\n auto buf = tbuffer(T[].init);\n enum source = buf.source;\n\n int i = 1;\n\n// Teach the producer.\n// This is a delegate as it accesses i.\n buf ~= (T[] arr)\n {\n\tarr[0] = T.init;\n\treturn i;\n };\n\nassert(buf.length == 0);\n\n// Request data if available\n buf ~= source;\n\n ---\n"
}
],
"comment": " $(P Optimized containers alike to arrays)\n\n\n <a href=\"https://cyroxin.github.io/Elembuf/index.html\"><<\/a>\n Macros:\n SOURCE = <a href=\"https://cyroxin.github.io/Elembuf/source.html\">docs/source<\/a>\n BUFFER = <a href=\"https://cyroxin.github.io/Elembuf/elembuf.html\">docs/buffer<\/a>\nExample:\n$(BR) $(P $(BIG $(B Whole library can be used in 5 lines. No new methods to remember while beating the efficiency of arrays and queues.))) $(BR) $(BR)$(DDOX_UNITTEST_HEADER __unittest_L16_C1)\n---\n\n\t// Import\n\timport elembuf;\n\n\t// Instantiate\n\tauto buf = buffer(\"Hello \");\n\n\t// Ensure new data fits\n\tassert(buf.max >= \"world!\".length + buf.length); \n\n\t// Fill\n\tbuf ~= \"world!\";\n\n\t// Read\n\tassert(buf == \"Hello world!\");\n\n---\n$(DDOX_UNITTEST_FOOTER __unittest_L16_C1)\nExample:\n$(BR) $(BIG $(B IO - Fast library integration))\n\n$(P $(BIG No outdated push/pop methods. IO libraries that require pointers work out of the box. Just use a lambda. )) $(BR) $(BR)\n\n\n$(BR)$(DDOX_UNITTEST_HEADER __unittest_L42_C1)\n---\n// Construct\nauto buf = buffer([1,2,3]);\n\nauto src = (int[] arr)\n{ \n\tarr[0] = 4;\n\treturn 1;\n};\n\n// Fill\nbuf ~= src;\nassert(buf == [1,2,3,4]);\n\n// Reuse\nbuf.length = 0;\nbuf ~= src;\nbuf ~= 5;\nassert(buf == [4,5]);\n\n---\n$(DDOX_UNITTEST_FOOTER __unittest_L42_C1)\nExample:\n$(BR) $(BIG $(B Concurrency - Built in for your convenience))\n\n$(P $(BIG Simple solution for single consumer-producer synchronization that works efficiently in the background without mutexes or slow synchronization keywords.)) $(BR) $(BR)\n\n\n$(BR)$(DDOX_UNITTEST_HEADER __unittest_L72_C1)\n---\nalias T = size_t; \n\n// Producer thread created\nauto buf = tbuffer((T[]).init); \n\nsize_t counter;\n\nsize_t delegate(T[]) source = (T[] arr)\n{ \n\t\tforeach(ref i; arr)\n\t\t{\n\t\t\ti = counter;\n\t\t\tcounter++;\n\t\t}\n\n\treturn arr.length;\n};\n\n// Give instructions to producer\nbuf ~= source; \n\n\nfor(int i; i < buf.max * 5; )\n{\n\twhile(buf.length == 0)\n\t{\n\t\t// Aquire data\n\t\tbuf ~= buf.source; \n\t}\n\n\ti += buf.length;\n\tbuf = buf[$..$];\n}\n\n// Unallocate all data &\n// destroy the thread.\n// Can be used for all buffers.\nbuf.deinit;\n\n---\n$(DDOX_UNITTEST_FOOTER __unittest_L72_C1)\nExample:\n$(BR) $(BIG $(B Mirroring - For Compression & Decryption))\n\n$(P $(BIG New item orders can easily be established without copying using a mirror provided by the operating system. )) $(BR) $(BR)\n\n\n\n$(BR) $(BR) $(P $(BIG Memory can be visualized as blocks of two $(BIG $(B O))'s, each having a size of $(BIG $(D_INLINECODE max/2)). The buffer only sees memory marked with $(BIG $(B X))'s.\nThe mirror border is marked with $(BIG $(B |)), right side of which is the mirrored memory. ))$(DDOX_UNITTEST_HEADER __unittest_L127_C1)\n---\n/+ Current view is OO|OO +/\nauto buf = buffer(\"\");\n\n// aO|aO\nbuf.ptr[0..buf.max/2] = 'a';\n\n// ab|ab\nbuf.ptr[buf.max/2 .. buf.max] = 'b';\n\n/+ Expand view from OO|OO +/\n\n// OX|XO\nbuf = buf.ptr[ buf.max / 2 .. buf.max + buf.max / 2 ];\n\n// ab|ab\nassert(buf[0] == 'b');\nassert(buf[$-1] == 'a');\n\n/+ Order: ab -> ba +/\n\n---\n$(DDOX_UNITTEST_FOOTER __unittest_L127_C1)\n",
"name": "elembuf"
},
{
"kind": "module",
"file": "source\\source.d",
"members": [
{
"kind": "struct",
"line": 74,
"char": 1,
"members": [
{
"line": 86,
"kind": "function",
"char": 7,
"name": "empty",
"deco": "FZb",
"endchar": 47,
"endline": 86,
"comment": "Checks if the socket has been closed by the sender. Does not check for data based closures (html or http).\n"
},
{
"parameters": [
{
"deco": "xAa",
"name": "url"
}
],
"line": 91,
"kind": "constructor",
"originalType": "ref @trusted (const char[] url)",
"char": 2,
"name": "this",
"deco": "FNcNexAaZS6source9NetSource",
"endchar": 2,
"endline": 120,
"comment": "Creates a connection by parsing an url from a string.\n"
}
],
"comment": " Source which takes data from a website.\n\n <a href=\"https://cyroxin.github.io/Elembuf/source.html\"><<\/a>\nExample:\n$(DDOX_UNITTEST_HEADER __unittest_L162_C1)\n---\nimport elembuf, source;\n\nauto buf = buffer(\"\");\nauto src = \"www.bing.com\".NetSource;\n\nwhile(buf.length == 0)\n\tbuf ~= src;\n\n---\n$(DDOX_UNITTEST_FOOTER __unittest_L162_C1)\n",
"name": "NetSource"
},
{
"parameters": [
{
"kind": "type",
"defaultDeco": "a",
"name": "InternalType"
}
],
"line": 179,
"kind": "template",
"char": 1,
"members": [
{
"kind": "struct",
"char": 1,
"members": [
{
"parameters": [],
"line": 185,
"kind": "template",
"char": 2,
"members": [
{
"parameters": [
{
"type": "T[]",
"name": "array"
}
],
"line": 185,
"kind": "constructor",
"char": 2,
"name": "this",
"type": "@nogc (T[] array)",
"endchar": 2,
"endline": 188
}
],
"name": "this",
"comment": "Takes in the array and stores it.\n"
}
],
"line": 179,
"name": "ArraySource"
}
],
"name": "ArraySource",
"comment": " Source that reads from an array as if it were a true source.\n\n <a href=\"https://cyroxin.github.io/Elembuf/source.html\"><<\/a>\nExample:\n$(DDOX_UNITTEST_HEADER __unittest_L217_C1)\n---\nimport elembuf, source;\n\nauto buf = buffer(\"\");\nauto src = \"World\".ArraySource!char;\n\nbuf ~= src;\nassert(buf == \"World\");\n\n---\n$(DDOX_UNITTEST_FOOTER __unittest_L217_C1)\nExample:\n$(DDOX_UNITTEST_HEADER __unittest_L229_C1)\n---\nimport elembuf, source;\n\nauto buf = buffer([0]);\nauto src = ([1,2,3,4,5]).ArraySource!int;\n\nbuf ~= src;\nassert(buf == [0,1,2,3,4,5]);\n\n---\n$(DDOX_UNITTEST_FOOTER __unittest_L229_C1)\n"
}
],
"comment": " $(P Data sources that may be used with buffers instead of directly filling or using lambdas)\n\n <a href=\"https://cyroxin.github.io/Elembuf/index.html\"><<\/a>\n Macros:\n SOURCE = <a href=\"https://cyroxin.github.io/Elembuf/source.html\">docs/source<\/a>\n BUFFER = <a href=\"https://cyroxin.github.io/Elembuf/elembuf.html\">docs/buffer<\/a>\nExample:\n$(BR) $(BIG $(B Extension Interface))\n\n$(BIG It is possible to have objects act as sources by inserting a lamda returning function in a struct or class. ) $(BR) $(BR)\n\n\n$(BR)$(DDOX_UNITTEST_HEADER __unittest_L22_C1)\n---\n \nstruct mystruct(T)\n{\n auto src()\n {\n return (T[] x) \n {\n // Write to x\n x[] = x.init;\n\t\t\n // Return written count\n return x.length;\n };\n }\t\n}\n\n\n---\n$(DDOX_UNITTEST_FOOTER __unittest_L22_C1)\nExample:\n$(BR) $(BIG $(B Built-in Sources ))\n\n$(P $(BIG There are built-in example sources, which you may use instead of directly filling using concat or lambdas. )) $(BR) $(BR)\n\n\n$(BR)$(DDOX_UNITTEST_HEADER __unittest_L51_C1)\n---\nimport source;\nimport elembuf;\n\nauto buf = buffer(\"\");\nauto src = \"www.bing.com\".NetSource;\n\nwhile(buf.length == 0)\n\tbuf ~= src;\n\n auto srcarr = \"World\".ArraySource!char;\n\n buf.length = 0;\n buf ~= srcarr;\n assert(buf == \"World\");\n\n\n---\n$(DDOX_UNITTEST_FOOTER __unittest_L51_C1)\n",
"name": "source"
}
]