Source

fparsec / Doc / html / reference / staticmapping.html

  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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <title>FParsec.StaticMapping</title>
 <link rel="stylesheet" type="text/css" media="all" href="../css/style.css" />
 <link rel="stylesheet" type="text/css" media="screen" href="../css/screen-sidebar.css" />
 <!--[if lt IE 9]>
 <link rel="stylesheet" type="text/css" media="all" href="../css/style-ie.css" />
 <![endif]-->
 <!--[if IE 6]>
 <link rel="stylesheet" type="text/css" media="all" href="../css/style-ie6.css" />
 <![endif]-->
 <link rel="stylesheet" type="text/css" media="print" href="../css/print.css" />
</head>
<body>
 <div id="fixed-layer">
 <div id="fixed-wrapper">
 <div id="sidebar">
  <div id="top-links"><span><a href="http://bitbucket.org/fparsec/main">FParsec @ BitBucket</a> | <a href="https://bitbucket.org/fparsec/main/issues">Report a bug</a> | <a href="mailto:fparsec [at] quanttec.com?subject=FParsec&amp;body=Hello Stephan,%0A%0A[your feedback]">Feedback</a></span></div>
  <div id="nav-tree">
   <table class="nav n1">
    <tbody class="nav-open n1">
     <tr class="nav-entry n1 _1">
      <td class="nav-number n1"></td>
      <td class="nav-title n1"><a href="../index.html">FParsec Documentation</a></td>
     </tr>
     <tr class="nav-subentries n1 _1">
      <td class="nav-subentries-number n1"></td>
      <td class="nav-subentries n1">
       <table class="nav n2">
        <tbody class="nav-before-open n2">
         <tr class="nav-entry n2 _1">
          <td class="nav-number n2"><a href="../about/index.html"><span class="section-number">1</span><span class="nav-space"></span></a></td>
          <td class="nav-title n2"><a href="../about/index.html">About FParsec</a></td>
         </tr>
         <tr class="nav-entry n2 _2">
          <td class="nav-number n2"><a href="../license.html"><span class="section-number">2</span><span class="nav-space"></span></a></td>
          <td class="nav-title n2"><a href="../license.html">License</a></td>
         </tr>
         <tr class="nav-entry n2 _3">
          <td class="nav-number n2">
           <a href="../download-and-installation.html"><span class="section-number">3</span><span class="nav-space"></span></a>
          </td>
          <td class="nav-title n2"><a href="../download-and-installation.html">Download and installation</a></td>
         </tr>
         <tr class="nav-entry n2 _4">
          <td class="nav-number n2"><a href="../tutorial.html"><span class="section-number">4</span><span class="nav-space"></span></a></td>
          <td class="nav-title n2"><a href="../tutorial.html">Tutorial</a></td>
         </tr>
         <tr class="nav-entry n2 _5">
          <td class="nav-number n2"><a href="../users-guide/index.html"><span class="section-number">5</span><span class="nav-space"></span></a></td>
          <td class="nav-title n2"><a href="../users-guide/index.html">User’s Guide</a></td>
         </tr>
        </tbody>
        <tbody class="nav-open n2">
         <tr class="nav-entry n2 _6">
          <td class="nav-number n2"><a href="index.html"><span class="section-number">6</span><span class="nav-space"></span></a></td>
          <td class="nav-title n2"><a href="index.html">Reference</a></td>
         </tr>
         <tr class="nav-subentries n2 _6">
          <td class="nav-subentries-number n2"></td>
          <td class="nav-subentries n2">
           <table class="nav n3">
            <tbody class="nav-before-open n3">
             <tr class="nav-entry n3 _1">
              <td class="nav-number n3"><a href="parser-overview.html"><span class="section-number">1</span><span class="nav-space"></span></a></td>
              <td class="nav-title n3"><a href="parser-overview.html">Parser overview</a></td>
             </tr>
             <tr class="nav-entry n3 _2">
              <td class="nav-number n3"><a href="primitives.html"><span class="section-number">2</span><span class="nav-space"></span></a></td>
              <td class="nav-title n3"><a href="primitives.html">FParsec.Primitives</a></td>
             </tr>
             <tr class="nav-entry n3 _3">
              <td class="nav-number n3"><a href="charparsers.html"><span class="section-number">3</span><span class="nav-space"></span></a></td>
              <td class="nav-title n3"><a href="charparsers.html">FParsec.CharParsers</a></td>
             </tr>
             <tr class="nav-entry n3 _4">
              <td class="nav-number n3">
               <a href="operatorprecedenceparser.html"><span class="section-number">4</span><span class="nav-space"></span></a>
              </td>
              <td class="nav-title n3"><a href="operatorprecedenceparser.html">FParsec.OperatorPrecedenceParser</a></td>
             </tr>
            </tbody>
            <tbody class="nav-open selected n3">
             <tr class="nav-entry selected n3 _5">
              <td class="nav-number selected n3"><a href="#"><span class="section-number">5</span><span class="nav-space"></span></a></td>
              <td class="nav-title selected n3"><a href="#">FParsec.StaticMapping</a></td>
             </tr>
             <tr class="nav-subentries selected n3 _5">
              <td class="nav-subentries-number selected n3"></td>
              <td class="nav-subentries selected n3">
               <table class="nav n4">
                <tbody class="nav-before-open n4">
                 <tr class="nav-entry n4 _1">
                  <td class="nav-number n4"><a href="#interface"><span class="section-number">1</span><span class="nav-space"></span></a></td>
                  <td class="nav-title n4"><a href="#interface">Interface</a></td>
                 </tr>
                 <tr class="nav-entry n4 _2">
                  <td class="nav-number n4"><a href="#remarks"><span class="section-number">2</span><span class="nav-space"></span></a></td>
                  <td class="nav-title n4"><a href="#remarks">Remarks</a></td>
                 </tr>
                 <tr class="nav-entry n4 _3">
                  <td class="nav-number n4"><a href="#members"><span class="section-number">3</span><span class="nav-space"></span></a></td>
                  <td class="nav-title n4"><a href="#members">Members</a></td>
                 </tr>
                </tbody>
               </table>
              </td>
             </tr>
            </tbody>
            <tbody class="nav-after-open n3">
             <tr class="nav-entry n3 _6">
              <td class="nav-number n3"><a href="reply.html"><span class="section-number">6</span><span class="nav-space"></span></a></td>
              <td class="nav-title n3"><a href="reply.html">FParsec.Reply</a></td>
             </tr>
             <tr class="nav-entry n3 _7">
              <td class="nav-number n3"><a href="error.html"><span class="section-number">7</span><span class="nav-space"></span></a></td>
              <td class="nav-title n3"><a href="error.html">FParsec.Error</a></td>
             </tr>
             <tr class="nav-entry n3 _8">
              <td class="nav-number n3"><a href="errormessage.html"><span class="section-number">8</span><span class="nav-space"></span></a></td>
              <td class="nav-title n3"><a href="errormessage.html">FParsec.ErrorMessage</a></td>
             </tr>
             <tr class="nav-entry n3 _9">
              <td class="nav-number n3"><a href="errormessagelist.html"><span class="section-number">9</span><span class="nav-space"></span></a></td>
              <td class="nav-title n3"><a href="errormessagelist.html">FParsec.ErrorMessageList</a></td>
             </tr>
             <tr class="nav-entry n3 _0">
              <td class="nav-number n3"><a href="position.html"><span class="section-number">10</span><span class="nav-space"></span></a></td>
              <td class="nav-title n3"><a href="position.html">FParsec.Position</a></td>
             </tr>
             <tr class="nav-entry n3 _1">
              <td class="nav-number n3"><a href="charstream.html"><span class="section-number">11</span><span class="nav-space"></span></a></td>
              <td class="nav-title n3"><a href="charstream.html">FParsec.CharStream</a></td>
             </tr>
             <tr class="nav-entry n3 _2">
              <td class="nav-number n3"><a href="text.html"><span class="section-number">12</span><span class="nav-space"></span></a></td>
              <td class="nav-title n3"><a href="text.html">FParsec.Text</a></td>
             </tr>
            </tbody>
           </table>
          </td>
         </tr>
        </tbody>
       </table>
      </td>
     </tr>
    </tbody>
   </table>
  </div>
  <div id="copyright">
    <span>Copyright © 2012 <a href="../about/contact.html">Stephan Tolksdorf</a></span>
  </div>
 </div>
 </div>
 </div>
 <div id="wrapper">
 <div id="main">
 <div id="main-content">
 <div id="breadcrumbs">
  <span class="breadcrumbs">
   <span id="breadcrumbs-parents"><a href="../index.html">FParsec Documentation</a><span class="breadcrumbs-sep"> > </span><a href="index.html">Reference</a></span><span class="breadcrumbs-sep"> > </span>FParsec.StaticMapping
  </span>
 </div>
 <div class="section s2">
  <h1 class="title h2"><span><span class="section-number">6.5</span> FParsec.StaticMapping</span></h1>
  <div class="intro i2">
   <div class="para _1">
    <p>This module defines functions for creating optimized mapping functions between keys and values.</p>
   </div>
   <div class="para _2">
    <p>This module is not available in the <a href="../download-and-installation.html#low-trust-version">Low‐Trust version</a> of FParsec.</p>
   </div>
  </div>
  <div id="interface" class="section s3">
   <h2 class="title h3"><span><span class="section-number">6.5.1</span> Interface</span></h2>
   <div class="intro i3">
    <div class="para _1 lcinp">
     <div class="interface-code">
<pre class="code fsharp"><span class="clc"><span class="cld">//</span> FParsec.dll</span>

<span class="ck">namespace</span> <span class="ci">FParsec</span>

<span class="ck">type</span> <a id="interface.Range:B:" href="#members.Range"><span class="interface-member-marker"><span class="ci">Range</span></span></a> <span class="cp">=</span> <span class="ck">struct</span>
  <span class="ck">new</span><span class="cp">:</span> <span class="ci">min</span><span class="cp">:</span> <span class="ci">int</span> <span class="cp">*</span> <span class="ci">max</span><span class="cp">:</span> <span class="ci">int</span> <span class="cr">-&gt;</span> <a href="#members.Range"><span class="ci">Range</span></a>

  <span class="ck">val</span> <span class="ci">Min</span><span class="cp">:</span> <span class="ci">int</span>
  <span class="ck">val</span> <span class="ci">Max</span><span class="cp">:</span> <span class="ci">int</span>
<span class="ck">end</span>

<span class="ck">module</span> <span class="ci">StaticMapping</span> <span class="cp">=</span>

  <span class="ck">val</span> <a id="interface.createStaticCharIndicatorFunction:B:" href="#members.createStaticCharIndicatorFunction"><span class="interface-member-marker"><span class="ci">createStaticCharIndicatorFunction</span></span></a><span class="cp">:</span>
          <span class="ci">invert</span><span class="cp">:</span> <span class="ci">bool</span> <span class="cr">-&gt;</span> <span class="ci">charsInSet</span><span class="cp">:</span> <span class="ci">seq</span><span class="cp">&lt;</span><span class="ci">char</span><span class="cp">&gt;</span>   <span class="cr">-&gt;</span> <span class="cp">(</span><span class="ci">char</span> <span class="cr">-&gt;</span> <span class="ci">bool</span><span class="cp">)</span>

  <span class="ck">val</span> <a id="interface.createStaticCharRangeIndicatorFunction:B:" href="#members.createStaticCharRangeIndicatorFunction"><span class="interface-member-marker"><span class="ci">createStaticCharRangeIndicatorFunction</span></span></a><span class="cp">:</span>
          <span class="ci">invert</span><span class="cp">:</span> <span class="ci">bool</span> <span class="cr">-&gt;</span> <span class="ci">rangesInSet</span><span class="cp">:</span> <span class="ci">seq</span><span class="cp">&lt;</span><a href="#members.Range"><span class="ci">Range</span></a><span class="cp">&gt;</span> <span class="cr">-&gt;</span> <span class="cp">(</span><span class="ci">char</span> <span class="cr">-&gt;</span> <span class="ci">bool</span><span class="cp">)</span>

  <span class="ck">val</span> <a id="interface.createStaticIntIndicatorFunction:B:" href="#members.createStaticIntIndicatorFunction"><span class="interface-member-marker"><span class="ci">createStaticIntIndicatorFunction</span></span></a><span class="cp">:</span>
          <span class="ci">invert</span><span class="cp">:</span> <span class="ci">bool</span> <span class="cr">-&gt;</span> <span class="ci">valuesInSet</span><span class="cp">:</span> <span class="ci">seq</span><span class="cp">&lt;</span><span class="ci">int</span><span class="cp">&gt;</span>   <span class="cr">-&gt;</span> <span class="cp">(</span><span class="ci">int</span> <span class="cr">-&gt;</span> <span class="ci">bool</span><span class="cp">)</span>

  <span class="ck">val</span> <a id="interface.createStaticIntRangeIndicatorFunction:B:" href="#members.createStaticIntRangeIndicatorFunction"><span class="interface-member-marker"><span class="ci">createStaticIntRangeIndicatorFunction</span></span></a><span class="cp">:</span>
          <span class="ci">invert</span><span class="cp">:</span> <span class="ci">bool</span> <span class="cr">-&gt;</span> <span class="ci">rangesInSet</span><span class="cp">:</span> <span class="ci">seq</span><span class="cp">&lt;</span><a href="#members.Range"><span class="ci">Range</span></a><span class="cp">&gt;</span> <span class="cr">-&gt;</span> <span class="cp">(</span><span class="ci">int</span> <span class="cr">-&gt;</span> <span class="ci">bool</span><span class="cp">)</span>


  <span class="ck">val</span> <a id="interface.createStaticIntMapping:B:" href="#members.createStaticIntMapping"><span class="interface-member-marker"><span class="ci">createStaticIntMapping</span></span></a><span class="cp">:</span>
          <span class="ci">defaultValue</span><span class="cp">:</span> <span class="ctv">'T</span> <span class="cr">-&gt;</span> <span class="ci">keyValues</span><span class="cp">:</span> <span class="ci">seq</span><span class="cp">&lt;</span><span class="ci">int</span><span class="cp">*</span><span class="ctv">'T</span><span class="cp">&gt;</span>   <span class="cr">-&gt;</span> <span class="cp">(</span><span class="ci">int</span> <span class="cr">-&gt;</span> <span class="ctv">'T</span><span class="cp">)</span>

  <span class="ck">val</span> <a id="interface.createStaticIntRangeMapping:B:" href="#members.createStaticIntRangeMapping"><span class="interface-member-marker"><span class="ci">createStaticIntRangeMapping</span></span></a><span class="cp">:</span>
          <span class="ci">defaultValue</span><span class="cp">:</span> <span class="ctv">'T</span> <span class="cr">-&gt;</span> <span class="ci">keyValues</span><span class="cp">:</span> <span class="ci">seq</span><span class="cp">&lt;</span><a href="#members.Range"><span class="ci">Range</span></a><span class="cp">*</span><span class="ctv">'T</span><span class="cp">&gt;</span> <span class="cr">-&gt;</span> <span class="cp">(</span><span class="ci">int</span> <span class="cr">-&gt;</span> <span class="ctv">'T</span><span class="cp">)</span>


  <span class="ck">val</span> <a id="interface.createStaticStringMapping:B:" href="#members.createStaticStringMapping"><span class="interface-member-marker"><span class="ci">createStaticStringMapping</span></span></a><span class="cp">:</span>
          <span class="ci">defaultValue</span><span class="cp">:</span> <span class="ctv">'T</span> <span class="cr">-&gt;</span> <span class="ci">keyValues</span><span class="cp">:</span> <span class="ci">seq</span><span class="cp">&lt;</span><span class="ci">string</span><span class="cp">*</span><span class="ctv">'T</span><span class="cp">&gt;</span> <span class="cr">-&gt;</span> <span class="cp">(</span><span class="ci">string</span> <span class="cr">-&gt;</span> <span class="ctv">'T</span><span class="cp">)</span>

</pre>
     </div>
    </div>
   </div>
  </div>
  <div id="remarks" class="section s3">
   <h2 class="title h3"><span><span class="section-number">6.5.2</span> Remarks</span></h2>
   <div class="intro i3">
    <div class="para _1">
     <p>
      The functions in the <code class="fsharp"><span class="ci">StaticMapping</span></code> module use runtime code generation via <code
      class="fsharp"><span class="ci">System</span><span class="cm">.</span><span class="ci">Reflection</span><span class="cm">.</span><span
      class="ci">Emit</span></code> to create optimized mapping functions between keys and values.
     </p>
    </div>
    <div class="para _2 lcinp">
     <div class="admonition">
      <div class="admonition-title">Note</div>
      <div class="admonition-body">
       <div class="para _1">
        <p>
         Runtime code generation is relatively expensive, so the functions in this module should only be used for optimizing static mappings that are
         potentially called a (very) large number of times.
        </p>
       </div>
      </div>
     </div>
    </div>
    <div class="para _3 lcinp">
     <div class="admonition">
      <div class="admonition-title">Note</div>
      <div class="admonition-body">
       <div class="para _1">
        <p>The code generated for the optimized mapping functions will occupy memory until the associated AppDomain is unloaded.</p>
       </div>
      </div>
     </div>
    </div>
    <div class="para _4">
     <p>
      The performance of the generated functions depends a lot on the individual key‐value mapping and the application‐specific call pattern. Ignoring
      the overhead of the function call, the generated mapping functions should generally be as fast as an equivalent statically compiled
      switch‐statement in C# or F#. In certain cases they will even be faster.
     </p>
    </div>
    <div class="para _5">
     <p>
      The code size of the generated functions increases about linearly with the number of key ranges (i.e. continuous sequences of keys with the same
      value). Hence, you should only use the <code class="fsharp"><span class="ci">StaticMapping</span></code> module for small mappings. If you try
      to turn arbitrarily large key‐value mappings into static mapping functions, you’ll likely hit upon certain implementation limitations (of this
      module’s code, of <code class="fsharp"><span class="ci">Reflection</span><span class="cm">.</span><span class="ci">Emit</span></code> or of the
      CLR’s JIT).
     </p>
    </div>
    <div class="para _6">
     <p>
      <span class="a" id="remarks.DEBUG_STATIC_MAPPING"></span> If the conditional compilation symbol <code class="fsharp"><a
      href="#remarks.DEBUG_STATIC_MAPPING"><span class="ci">DEBUG_STATIC_MAPPING</span></a></code> is defined when compiling FParsec, the generated
      mapping functions will compute each result with two different methods and check the results against each other. Of course, this means that they
      will take more than twice the time than without the <code class="fsharp"><a href="#remarks.DEBUG_STATIC_MAPPING"><span
      class="ci">DEBUG_STATIC_MAPPING</span></a></code> symbol and will also consume more memory. In Debug builds of FParsec <code class="fsharp"><a
      href="#remarks.DEBUG_STATIC_MAPPING"><span class="ci">DEBUG_STATIC_MAPPING</span></a></code> is switched on by default, since the <code
      class="fsharp"><span class="ci">StaticMapping</span></code> module is still very new.
     </p>
    </div>
    <div class="para _7 lcinp">
     <div class="admonition">
      <div class="admonition-title">Note</div>
      <div class="admonition-body">
       <div class="para _1">
        <p>Measuring and comparing the performance of the generated mapping functions only makes sense in Release builds.</p>
       </div>
      </div>
     </div>
    </div>
   </div>
  </div>
  <div id="members" class="section s3">
   <h2 class="title h3"><span><span class="section-number">6.5.3</span> Members</span></h2>
   <div class="intro i3">
    <div class="para _1 lcinp">
     <div class="interface-members">
      <div class="interface-member _1" id="members.Range">
       <div class="interface-member-code">
        <a class="interface-member-backlink" href="#interface.Range:B:"></a>
<pre class="code fsharp"><span class="ck">type</span> <span class="interface-member-marker"><span class="ci">Range</span></span></pre>
       </div>
       <div class="interface-member-description">
        <div class="para _1">
         <p>
          Represents an immutable range between the integer values <code class="fsharp"><span class="ci">Min</span></code> and <code
          class="fsharp"><span class="ci">Max</span></code> (inclusive).
         </p>
        </div>
        <div class="para _2 lcinp">
<pre class="code fsharp"><span class="ck">type</span> <span class="ci">Range</span> <span class="cp">=</span> <span class="ck">struct</span>
  <span class="ck">new</span><span class="cp">:</span> <span class="ci">min</span><span class="cp">:</span> <span class="ci">int</span> <span class="cp">*</span> <span class="ci">max</span><span class="cp">:</span> <span class="ci">int</span> <span class="cr">-&gt;</span> <span class="ci">Range</span>

  <span class="ck">val</span> <span class="ci">Min</span><span class="cp">:</span> <span class="ci">int</span>
  <span class="ck">val</span> <span class="ci">Max</span><span class="cp">:</span> <span class="ci">int</span>
<span class="ck">end</span>
</pre>
        </div>
        <div class="para _3">
         <p>
          The <code class="fsharp"><span class="ci">Min</span></code> value must not be larger than the <code class="fsharp"><span
          class="ci">Max</span></code> value. In a Debug build this condition is checked by an assert‐check in the <code class="fsharp"><span
          class="ci">Range</span></code> constructor.
         </p>
        </div>
       </div>
      </div>
      <div class="interface-member _2" id="members.createStaticCharIndicatorFunction">
       <div class="interface-member-code">
        <a class="interface-member-backlink" href="#interface.createStaticCharIndicatorFunction:B:"></a>
<pre class="code fsharp"><span class="ck">val</span> <span class="interface-member-marker"><span class="ci">createStaticCharIndicatorFunction</span></span><span class="cp">:</span>
        <span class="ci">invert</span><span class="cp">:</span> <span class="ci">bool</span> <span class="cr">-&gt;</span> <span class="ci">charsInSet</span><span class="cp">:</span> <span class="ci">seq</span><span class="cp">&lt;</span><span class="ci">char</span><span class="cp">&gt;</span> <span class="cr">-&gt;</span> <span class="cp">(</span><span class="ci">char</span> <span class="cr">-&gt;</span> <span class="ci">bool</span><span class="cp">)</span>
</pre>
       </div>
       <div class="interface-member-description">
        <div class="para _1">
         <p>
          Creates an optimized indicator function for the chars specified by the <code class="fsharp"><span class="ci">charsInSet</span></code>
          sequence.
         </p>
        </div>
        <div class="para _2">
         <p>
          If <code class="fsharp"><span class="ci">invert</span></code> is <code class="fsharp"><span class="cb">false</span></code> (<code
          class="fsharp"><span class="cb">true</span></code>), the returned indicator function will return <code class="fsharp"><span
          class="cb">true</span></code> (<code class="fsharp"><span class="cb">false</span></code>) if and only if it is called with a char contained
          in <code class="fsharp"><span class="ci">charsInSet</span></code>.
         </p>
        </div>
        <div class="para _3">
         <p><code class="fsharp"><span class="ci">charsInSet</span></code> may contain duplicate char values.</p>
        </div>
        <div class="para _4">
         <p>
          Internally, this function collects continuous ranges of chars into <code class="fsharp"><a href="#members.Range"><span
          class="ci">Range</span></a></code> values and then uses the same compilation strategy as <code class="fsharp"><a
          href="#members.createStaticCharRangeIndicatorFunction"><span class="ci">createStaticCharRangeIndicatorFunction</span></a></code>.
         </p>
        </div>
        <div class="para _5">
         <p>Please also see the <a href="#remarks">remarks</a> at the beginning of this section.</p>
        </div>
       </div>
      </div>
      <div class="interface-member _3" id="members.createStaticCharRangeIndicatorFunction">
       <div class="interface-member-code">
        <a class="interface-member-backlink" href="#interface.createStaticCharRangeIndicatorFunction:B:"></a>
<pre class="code fsharp"><span class="ck">val</span> <span class="interface-member-marker"><span class="ci">createStaticCharRangeIndicatorFunction</span></span><span class="cp">:</span>
        <span class="ci">invert</span><span class="cp">:</span> <span class="ci">bool</span> <span class="cr">-&gt;</span> <span class="ci">rangesInSet</span><span class="cp">:</span> <span class="ci">seq</span><span class="cp">&lt;</span><a href="#members.Range"><span class="ci">Range</span></a><span class="cp">&gt;</span> <span class="cr">-&gt;</span> <span class="cp">(</span><span class="ci">char</span> <span class="cr">-&gt;</span> <span class="ci">bool</span><span class="cp">)</span>
</pre>
       </div>
       <div class="interface-member-description">
        <div class="para _1">
         <p>
          Creates an optimized indicator function for the chars in the ranges specified by the <code class="fsharp"><span
          class="ci">rangesInSet</span></code> sequence.
         </p>
        </div>
        <div class="para _2">
         <p>
          If <code class="fsharp"><span class="ci">invert</span></code> is <code class="fsharp"><span class="cb">false</span></code> (<code
          class="fsharp"><span class="cb">true</span></code>), the returned indicator function will return <code class="fsharp"><span
          class="cb">true</span></code> (<code class="fsharp"><span class="cb">false</span></code>) if and only if it is called with a char contained
          in at least one of the ranges of <code class="fsharp"><span class="ci">rangesInSet</span></code>.
         </p>
        </div>
        <div class="para _3">
         <p>
          <code class="fsharp"><span class="ci">rangesInSet</span></code> may contain overlapping or duplicate ranges. However, the ranges must not
          contain values less than <code class="fsharp"><span class="cn">0</span></code> or greater than <code class="fsharp"><span
          class="cn">0xffff</span></code> (the minimum and maximum UTF‐16 char values), otherwise an <code class="fsharp"><a
          href="http://msdn.microsoft.com/en-us/library/system.argumentexception.aspx"><span class="ci">ArgumentException</span></a></code> is thrown.
         </p>
        </div>
        <div class="para _4">
         <p>Please also see the <a href="#remarks">remarks</a> at the beginning of this section.</p>
        </div>
       </div>
      </div>
      <div class="interface-member _4" id="members.createStaticIntIndicatorFunction">
       <div class="interface-member-code">
        <a class="interface-member-backlink" href="#interface.createStaticIntIndicatorFunction:B:"></a>
<pre class="code fsharp"><span class="ck">val</span> <span class="interface-member-marker"><span class="ci">createStaticIntIndicatorFunction</span></span><span class="cp">:</span>
        <span class="ci">invert</span><span class="cp">:</span> <span class="ci">bool</span> <span class="cr">-&gt;</span> <span class="ci">valuesInSet</span><span class="cp">:</span> <span class="ci">seq</span><span class="cp">&lt;</span><span class="ci">int</span><span class="cp">&gt;</span> <span class="cr">-&gt;</span> <span class="cp">(</span><span class="ci">int</span> <span class="cr">-&gt;</span> <span class="ci">bool</span><span class="cp">)</span>
</pre>
       </div>
       <div class="interface-member-description">
        <div class="para _1">
         <p>
          Creates an optimized indicator function for the integers specified by the <code class="fsharp"><span class="ci">valuesInSet</span></code>
          sequence.
         </p>
        </div>
        <div class="para _2">
         <p>
          If <code class="fsharp"><span class="ci">invert</span></code> is <code class="fsharp"><span class="cb">false</span></code> (<code
          class="fsharp"><span class="cb">true</span></code>), the returned indicator function will return <code class="fsharp"><span
          class="cb">true</span></code> (<code class="fsharp"><span class="cb">false</span></code>) if and only if it is called with an integer
          contained in <code class="fsharp"><span class="ci">valuesInSet</span></code>.
         </p>
        </div>
        <div class="para _3">
         <p><code class="fsharp"><span class="ci">valuesInSet</span></code> may contain duplicate integer values.</p>
        </div>
        <div class="para _4">
         <p>
          Internally, this function collects continues ranges of integer into <code class="fsharp"><a href="#members.Range"><span
          class="ci">Range</span></a></code> values and then uses the same compilation strategy as <code class="fsharp"><a
          href="#members.createStaticIntRangeIndicatorFunction"><span class="ci">createStaticIntRangeIndicatorFunction</span></a></code>.
         </p>
        </div>
        <div class="para _5">
         <p>Please also see the <a href="#remarks">remarks</a> at the beginning of this section.</p>
        </div>
       </div>
      </div>
      <div class="interface-member _5" id="members.createStaticIntRangeIndicatorFunction">
       <div class="interface-member-code">
        <a class="interface-member-backlink" href="#interface.createStaticIntRangeIndicatorFunction:B:"></a>
<pre class="code fsharp"><span class="ck">val</span> <span class="interface-member-marker"><span class="ci">createStaticIntRangeIndicatorFunction</span></span><span class="cp">:</span>
        <span class="ci">invert</span><span class="cp">:</span> <span class="ci">bool</span> <span class="cr">-&gt;</span> <span class="ci">rangesInSet</span><span class="cp">:</span> <span class="ci">seq</span><span class="cp">&lt;</span><a href="#members.Range"><span class="ci">Range</span></a><span class="cp">&gt;</span> <span class="cr">-&gt;</span> <span class="cp">(</span><span class="ci">int</span> <span class="cr">-&gt;</span> <span class="ci">bool</span><span class="cp">)</span>
</pre>
       </div>
       <div class="interface-member-description">
        <div class="para _1">
         <p>
          Creates an optimized indicator function for the integers in the ranges specified by the <code class="fsharp"><span
          class="ci">rangesInSet</span></code> sequence.
         </p>
        </div>
        <div class="para _2">
         <p>
          If <code class="fsharp"><span class="ci">invert</span></code> is <code class="fsharp"><span class="cb">false</span></code> (<code
          class="fsharp"><span class="cb">true</span></code>), the returned indicator function will return <code class="fsharp"><span
          class="cb">true</span></code> (<code class="fsharp"><span class="cb">false</span></code>) if and only if it is called with an <code
          class="fsharp"><span class="ci">int</span></code> contained in at least one of the ranges of <code class="fsharp"><span
          class="ci">rangesInSet</span></code>.
         </p>
        </div>
        <div class="para _3">
         <p><code class="fsharp"><span class="ci">rangesInSet</span></code> may contain overlapping or duplicate ranges.</p>
        </div>
        <div class="para _4">
         <p>Please also see the <a href="#remarks">remarks</a> at the beginning of this section.</p>
        </div>
       </div>
      </div>
      <div class="interface-member _6" id="members.createStaticIntMapping">
       <div class="interface-member-code">
        <a class="interface-member-backlink" href="#interface.createStaticIntMapping:B:"></a>
<pre class="code fsharp"><span class="ck">val</span> <span class="interface-member-marker"><span class="ci">createStaticIntMapping</span></span><span class="cp">:</span>
        <span class="ci">defaultValue</span><span class="cp">:</span> <span class="ctv">'T</span> <span class="cr">-&gt;</span> <span class="ci">keyValues</span><span class="cp">:</span> <span class="ci">seq</span><span class="cp">&lt;</span><span class="ci">int</span><span class="cp">*</span><span class="ctv">'T</span><span class="cp">&gt;</span> <span class="cr">-&gt;</span> <span class="cp">(</span><span class="ci">int</span> <span class="cr">-&gt;</span> <span class="ctv">'T</span><span class="cp">)</span>
</pre>
       </div>
       <div class="interface-member-description">
        <div class="para _1">
         <p>Creates an optimized mapping function that maps integer keys to values.</p>
        </div>
        <div class="para _2">
         <p>
          The <code class="fsharp"><span class="ci">keyValues</span></code> sequence specifies the key‐value pairs for the mapping. All keys not
          specified in <code class="fsharp"><span class="ci">keyValues</span></code> are mapped to <code class="fsharp"><span
          class="ci">defaultValue</span></code>.
         </p>
        </div>
        <div class="para _3">
         <p>
          This function throws an <code class="fsharp"><a href="http://msdn.microsoft.com/en-us/library/system.argumentexception.aspx"><span
          class="ci">ArgumentException</span></a></code> if <code class="fsharp"><span class="ci">keyValues</span></code> contains a duplicate key.
         </p>
        </div>
        <div class="para _4">
         <p>
          Internally, this function collects continues ranges of integer keys with equal values<sup class="fn-mark"><a id="members.:FN:1:B:"
          href="#members.:FN:1">[1]</a></sup> into <code class="fsharp"><a href="#members.Range"><span class="ci">Range</span></a></code> values and
          then uses the same compilation strategy as <code class="fsharp"><a href="#members.createStaticIntRangeMapping"><span
          class="ci">createStaticIntRangeMapping</span></a></code>.
         </p>
        </div>
        <div class="para _5">
         <p>Please also see the <a href="#remarks">remarks</a> at the beginning of this section.</p>
        </div>
       </div>
      </div>
      <div class="interface-member _7" id="members.createStaticIntRangeMapping">
       <div class="interface-member-code">
        <a class="interface-member-backlink" href="#interface.createStaticIntRangeMapping:B:"></a>
<pre class="code fsharp"><span class="ck">val</span> <span class="interface-member-marker"><span class="ci">createStaticIntRangeMapping</span></span><span class="cp">:</span>
        <span class="ci">defaultValue</span><span class="cp">:</span> <span class="ctv">'T</span> <span class="cr">-&gt;</span> <span class="ci">keyValues</span><span class="cp">:</span> <span class="ci">seq</span><span class="cp">&lt;</span><a href="#members.Range"><span class="ci">Range</span></a><span class="cp">*</span><span class="ctv">'T</span><span class="cp">&gt;</span> <span class="cr">-&gt;</span> <span class="cp">(</span><span class="ci">int</span> <span class="cr">-&gt;</span> <span class="ctv">'T</span><span class="cp">)</span>
</pre>
       </div>
       <div class="interface-member-description">
        <div class="para _1">
         <p>Creates an optimized mapping function that maps integer key ranges to values.</p>
        </div>
        <div class="para _2">
         <p>
          The <code class="fsharp"><span class="ci">keyValues</span></code> sequence specifies the range‐value pairs for the mapping. All keys not
          contained in one of the ranges in <code class="fsharp"><span class="ci">keyValues</span></code> are mapped to <code class="fsharp"><span
          class="ci">defaultValue</span></code>.
         </p>
        </div>
        <div class="para _3">
         <p>
          This function throws an <code class="fsharp"><a href="http://msdn.microsoft.com/en-us/library/system.argumentexception.aspx"><span
          class="ci">ArgumentException</span></a></code> if <code class="fsharp"><span class="ci">keyValues</span></code> contains an overlapping or
          duplicate key range.
         </p>
        </div>
        <div class="para _4">
         <p>Please also see the <a href="#remarks">remarks</a> at the beginning of this section.</p>
        </div>
       </div>
      </div>
      <div class="interface-member _8" id="members.createStaticStringMapping">
       <div class="interface-member-code">
        <a class="interface-member-backlink" href="#interface.createStaticStringMapping:B:"></a>
<pre class="code fsharp"><span class="ck">val</span> <span class="interface-member-marker"><span class="ci">createStaticStringMapping</span></span><span class="cp">:</span>
        <span class="ci">defaultValue</span><span class="cp">:</span> <span class="ctv">'T</span> <span class="cr">-&gt;</span> <span class="ci">keyValues</span><span class="cp">:</span> <span class="ci">seq</span><span class="cp">&lt;</span><span class="ci">string</span><span class="cp">*</span><span class="ctv">'T</span><span class="cp">&gt;</span> <span class="cr">-&gt;</span> <span class="cp">(</span><span class="ci">string</span> <span class="cr">-&gt;</span> <span class="ctv">'T</span><span class="cp">)</span>
</pre>
       </div>
       <div class="interface-member-description">
        <div class="para _1">
         <p>Creates an optimized mapping function that maps string keys to values.</p>
        </div>
        <div class="para _2">
         <p>
          The <code class="fsharp"><span class="ci">keyValues</span></code> sequence specifies the key‐value pairs for the mapping. All keys not
          specified in <code class="fsharp"><span class="ci">keyValues</span></code> are mapped to <code class="fsharp"><span
          class="ci">defaultValue</span></code>. A <code class="fsharp"><span class="cnu">null</span></code> key is not supported.
         </p>
        </div>
        <div class="para _3">
         <p>
          <code class="fsharp"><span class="ci">createStaticStringMapping</span></code> throws an <code class="fsharp"><a
          href="http://msdn.microsoft.com/en-us/library/system.argumentexception.aspx"><span class="ci">ArgumentException</span></a></code> if <code
          class="fsharp"><span class="ci">keyValues</span></code> contains a duplicate key or a <code class="fsharp"><span
          class="cnu">null</span></code> key. If the generated mapping function is called with a <code class="fsharp"><span
          class="cnu">null</span></code> string, it throws a <code class="fsharp"><a
          href="http://msdn.microsoft.com/en-us/library/system.nullreferenceexception.aspx"><span class="ci">NullReferenceException</span></a></code>.
         </p>
        </div>
        <div class="para _4 lcinp">
         <div class="admonition">
          <div class="admonition-title">Note</div>
          <div class="admonition-body">
           <div class="para _1">
            <p>
             The compilation strategy employed by <code class="fsharp"><span class="ci">createStaticStringMapping</span></code> does not handle all
             mappings equally well. It is optimized for mapping a relatively small set of string symbols to constants. If you want to use <code
             class="fsharp"><span class="ci">createStaticStringMapping</span></code> to optimize a frequently used mapping in your program, you should
             test how well <code class="fsharp"><span class="ci">createStaticStringMapping</span></code> handles your situation (in a Release build!)
             and see whether the performance is worth the compilation costs and the additional code dependency.
            </p>
           </div>
          </div>
         </div>
        </div>
        <div class="para _5">
         <p>Please also see the <a href="#remarks">remarks</a> at the beginning of this section.</p>
        </div>
       </div>
      </div>
     </div>
    </div>
   </div>
  </div>
  <div class="fn-list">
   <div class="fn-title">Footnotes:</div>
   <table class="fn">
    <tr class="fn _1">
     <th class="fn _1"><a class="footnote-backlink" id="members.:FN:1" href="#members.:FN:1:B:">[1]</a></th>
     <td class="fn _2">
      In the case of a reference type the values are only compared for reference‐equality. In the case of a value type the values are only compared if
      the type implements <code class="fsharp"><span class="ci">System</span><span class="cm">.</span><span class="ci">IEquality</span><span
      class="cp">&lt;</span><span class="ci">_</span><span class="cp">&gt;</span></code> or is an <code class="fsharp"><span
      class="ci">int</span></code> enum type.
     </td>
    </tr>
   </table>
  </div>
 </div>
 </div>
 </div>
 </div>
</body>
</html>