This file is indexed.

/usr/lib/ats2-postiats-0.2.6/libats/DATS/linheap_binomial2.dats is in ats2-lang 0.2.6-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
(***********************************************************************)
(*                                                                     *)
(*                         Applied Type System                         *)
(*                                                                     *)
(***********************************************************************)

(*
** ATS/Postiats - Unleashing the Potential of Types!
** Copyright (C) 2011-2013 Hongwei Xi, ATS Trustful Software, Inc.
** All rights reserved
**
** ATS is free software;  you can  redistribute it and/or modify it under
** the terms of  the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
** Free Software Foundation; either version 3, or (at  your  option)  any
** later version.
** 
** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
** WARRANTY; without  even  the  implied  warranty  of MERCHANTABILITY or
** FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
** for more details.
** 
** You  should  have  received  a  copy of the GNU General Public License
** along  with  ATS;  see the  file COPYING.  If not, please write to the
** Free Software Foundation,  51 Franklin Street, Fifth Floor, Boston, MA
** 02110-1301, USA.
*)

(* ****** ****** *)

(* Author: Hongwei Xi *)
(* Authoremail: hwxi AT cs DOT bu DOT edu *)
(* Start time: December, 2012 *)

(* ****** ****** *)
//
// HX: This implementation is of imperative style;
// it supports mergeable-heap operations and also
// the decrease-key operation.
//
(* ****** ****** *)

#define ATS_PACKNAME "ATSLIB.libats.linheap_binomial2"
#define ATS_DYNLOADFLAG 0 // no need for dynloading at run-time

(* ****** ****** *)

staload
UN = "prelude/SATS/unsafe.sats"

(* ****** ****** *)

staload "libats/SATS/gnode.sats"
staload "libats/SATS/linheap_binomial.sats"

(* ****** ****** *)

#define nullp the_null_ptr

(* ****** ****** *)
//
// HX-2012-12-21:
// the file should be included here
// before [heap_vtype] is assumed
//
#include "./SHARE/linheap.hats" // code reuse
//
(* ****** ****** *)

macdef assertloc_debug (x) = ()

(* ****** ****** *)

stadef
mytkind = $extkind"atslib_linheap_binomial2"

(* ****** ****** *)

typedef
g2node (a:vt0p, l:addr) = gnode (mytkind, a, l)
typedef g2node0 (a:vt0p) = gnode0 (mytkind, a)
typedef g2node1 (a:vt0p) = gnode1 (mytkind, a)

(* ****** ****** *)

extern
fun{a:vt0p}
g2node_make_elt (x: a):<!wrt> g2node1 (a)

(* ****** ****** *)

extern
fun{a:t0p}
g2node_free (nx: g2node1 (INV(a))):<!wrt> void

(* ****** ****** *)

extern
fun{a:vt0p}
g2node_free_elt
  (nx: g2node1 (INV(a)), res: &a? >> a):<!wrt> void
// end of [g2node_free_elt]

(* ****** ****** *)

extern
fun{a:vt0p}
g2node_get_rank (nx: g2node1 (INV(a))):<> int
extern
fun{a:vt0p}
g2node_set_rank (nx: g2node1 (INV(a)), r: int):<!wrt> void

extern
fun{a:vt0p}
g2node_get_parent (nx: g2node1 (INV(a))):<> g2node0 (a)
extern
fun{a:vt0p}
g2node_set_parent (nx: g2node1 (INV(a)), par: g2node0 (a)):<!wrt> void
extern
fun{a:vt0p}
g2node_set_parent_null (nx: g2node1 (INV(a))):<!wrt> void

extern
fun{a:vt0p}
g2node_get_children (nx: g2node1 (INV(a))):<> g2node0 (a)
extern
fun{a:vt0p}
g2node_set_children (nx: g2node1 (INV(a)), nxs: g2node0 (a)):<!wrt> void
extern
fun{a:vt0p}
g2node_set_children_null (nx: g2node1 (INV(a))):<!wrt> void

(* ****** ****** *)

extern
fun{a:vt0p}
g2nodelst_cons (nx: g2node1 (INV(a)), nxs: g2node0 (a)):<!wrt> g2node1 (a)

(* ****** ****** *)

extern
fun{a:vt0p}
gnode_compare
  (nx1: g2node1 (a), nx2: g2node1 (a)):<> int
implement{a}
gnode_compare
  (nx1, nx2) = sgn where {
  val p_x1 = gnode_getref_elt (nx1)
  val (
    pf1, fpf1 | p_x1
  ) = $UN.cptr_vtake (p_x1)
  val p_x2 = gnode_getref_elt (nx2)
  val (
    pf2, fpf2 | p_x2
  ) = $UN.cptr_vtake (p_x2)
  val sgn = compare_elt_elt<a> (!p_x1, !p_x2)
  prval () = fpf1 (pf1) and () = fpf2 (pf2)
} // end of [gnode_compare]

(* ****** ****** *)

extern
fun{a:vt0p}
gnode_compare01
  (nx1: g2node0 (a), nx2: g2node1 (a)):<> int
implement{a}
gnode_compare01
  (nx1, nx2) =
  if gnode_isnot_null (nx1) then gnode_compare<a> (nx1, nx2) else 1
// end of [gnode_compare01]

extern
fun{a:vt0p}
gnode_compare10
  (nx1: g2node1 (a), nx2: g2node0 (a)):<> int
implement{a}
gnode_compare10
  (nx1, nx2) =
  if gnode_isnot_null (nx2) then gnode_compare<a> (nx1, nx2) else ~1
// end of [gnode_compare10]

(* ****** ****** *)
//
// HX-2013-08:
// [nx1] and [nx2] are of the same rank
//
extern
fun{a:vt0p}
join_gnode_gnode
  (nx1: g2node1 (a), nx2: g2node1 (a)):<!wrt> void
implement{a}
join_gnode_gnode
  (nx1, nx2) = let
  val r = g2node_get_rank (nx1)
  val () = g2node_set_rank (nx1, r+1)
  val () = g2node_set_parent (nx2, nx1)
  val () = gnode_link10 (nx2, g2node_get_children (nx1))
  val () = g2node_set_children (nx1, nx2)
in
  // nothing
end // end of [join_gnode_gnode]

(* ****** ****** *)

extern
fun{a:vt0p}
merge_gnode_gnode
(
  nx1: g2node1 (a), nx2: g2node1 (a)
) :<!wrt> g2node1 (a) // endfun
implement{a}
merge_gnode_gnode
  (nx1, nx2) = let
  val sgn = gnode_compare<a> (nx1, nx2)
in
  if sgn < 0 then let
    val () = join_gnode_gnode<a> (nx1, nx2) in nx1
  end else let
    val () = join_gnode_gnode<a> (nx2, nx1) in nx2
  end // end of [if]
end // end of [merge_gnode_gnode]

(* ****** ****** *)

extern
fun{a:vt0p}
merge_gnode_gnodelst
(
  nx1: g2node1 (a), r1: int, nxs2: g2node0 (a)
) :<!wrt> g2node1 (a) // endfun
implement{a}
merge_gnode_gnodelst
  (nx1, r1, nxs2) = let
//
val iscons = gnodelst_is_cons (nxs2)
//
in
//
if iscons then let
  val nx2 = nxs2
  val r2 = g2node_get_rank (nx2)
in
  if r1 < r2 then
    g2nodelst_cons (nx1, nxs2)
  else let // HX: r1 = r2
    val nxs2 = gnode_get_next (nx2)
    val nx1 = merge_gnode_gnode<a> (nx1, nx2)
  in
    merge_gnode_gnodelst<a> (nx1, r1+1, nxs2)
  end // end of [if]
end else
  g2nodelst_cons (nx1, nxs2)
// end of [if]
//
end // end of [merge_gnode_gnodelst]

(* ****** ****** *)

(*
** HX-2012-12:
** pre-condition for merging_gnodelst_gnodelst:
** both [nxs1] and [nxs2] are sorted ascendingly
** according to ranks of binomial trees
*)
extern
fun{a:vt0p}
merge_gnodelst_gnodelst
(
  nxs1: g2node0 (a), nxs2: g2node0 (a)
) :<!wrt> g2node0 (a) // endfun
implement{a}
merge_gnodelst_gnodelst
  (nxs1, nxs2) = let
//
fun loop
(
  nxs1: g2node0 (a), nxs2: g2node0 (a), res: Ptr1
) : void = let
in
//
if gnode_isnot_null (nxs1) then (
  if gnode_isnot_null (nxs2) then let
    val nx1 = nxs1
    val r1 = g2node_get_rank (nx1)
    val nx2 = nxs2
    val r2 = g2node_get_rank (nx2)
  in
    if r1 < r2 then let
      val () =
        $UN.ptr1_set<g2node1(a)> (res, nx1)
      val res = gnode_getref_next (nx1)
      val nxs1 = $UN.cptr_get<g2node0(a)> (res)
    in
      loop (nxs1, nxs2, cptr2ptr (res))
    end else if r1 > r2 then let
      val () = 
        $UN.ptr1_set<g2node1(a)> (res, nx2)
      val res = gnode_getref_next (nx2)
      val nxs2 = $UN.cptr_get<g2node0(a)> (res)
    in
      loop (nxs1, nxs2, cptr2ptr (res))
    end else let // r1 = r2
      val nxs1 = gnode_get_next (nx1)
      val nxs2 = gnode_get_next (nx2)
      val nx1 = merge_gnode_gnode<a> (nx1, nx2)
      val nxs1 = merge_gnode_gnodelst<a> (nx1, r1+1, nxs1)
    in
      loop (nxs1, nxs2, res)
    end // end of [if]
  end else $UN.ptr1_set<g2node0(a)> (res, nxs1)
) else $UN.ptr1_set<g2node0(a)> (res, nxs2)
//
end // end of [loop]
//
var res: g2node0(a)
val () = $effmask_all (loop (nxs1, nxs2, addr@(res)))
//
in
  $UN.cast{g2node0(a)} (res)
end // end of [merge_gnodelst_gnodelst]

(* ****** ****** *)

(*
assume
heap_vtype (a:vt0p) = g2node0 (a)
*)

(* ****** ****** *)

implement{}
linheap_nil{a} () =
  $UN.castvwtp1{heap(a)}(gnode_null())
// end of [linheap_nil]

(* ****** ****** *)
//
implement{}
linheap_is_nil{a} (hp) =
  gnodelst_is_nil ($UN.castvwtp1{g2node0(a)}(hp))
implement{}
linheap_isnot_nil{a} (hp) =
  gnodelst_is_cons ($UN.castvwtp1{g2node0(a)}(hp))
//
(* ****** ****** *)

implement{a}
linheap_size (hp) = let
//
fun loop
(
  nxs: g2node0(a), res: size_t
) : size_t = let
//
val iscons = gnodelst_is_cons (nxs)
//
in
//
if iscons then let
  val nx = nxs
  val r = g2node_get_rank (nx)
  val r = $UN.cast{intGte(0)}(r)
  val nsz = g0uint_lsl_size ((i2sz)1, r)
  val nxs = gnode_get_next (nx)
in
  loop (nxs, res + nsz)
end else res // end of [if]
//
end // end of [loop]
//
in
  $effmask_all (loop ($UN.castvwtp1{g2node0(a)}(hp), i2sz(0)))
end // end of [linheap_size]

(* ****** ****** *)
  
implement{a}
linheap_insert
  (hp0, x0) = let
//
val nx = g2node_make_elt<a> (x0)
//
val () = gnode_set_next_null (nx)
//
val () = g2node_set_rank (nx, 0)
val () = g2node_set_parent_null (nx)
val () = g2node_set_children_null (nx)
//
val nxs = $UN.castvwtp0{g2node0(a)}(hp0)
val nxs = merge_gnode_gnodelst<a> (nx, 0, nxs)
val () = hp0 := $UN.castvwtp0{heap(a)}(nxs)
//
in
  // nothing
end // end of [linheap_insert]

(* ****** ****** *)

implement{a}
linheap_getmin_ref (hp0) = let
//
fun loop (
  nx0: g2node1 (a), nxs: g2node0 (a)
) : g2node0 (a) = let
  val iscons = gnodelst_is_cons (nxs)
in
//
if iscons then let
  val nx = nxs
  val nxs = gnode_get_next (nx)
  val sgn = gnode_compare<a> (nx0, nx)
in
  if sgn <= 0 then loop (nx0, nxs) else loop (nx, nxs)
end else nx0 // end of [if]
//
end // end of [loop]
//
var nxs =
  $UN.castvwtp1{g2node0(a)}(hp0)
val iscons = gnodelst_is_cons (nxs)
in
//
if iscons then let
  val nx = nxs
  val nxs = gnode_get_next (nx)
  val nx_min = loop (nx, nxs)
in
  $UN.cast{cPtr1(a)}(nx_min)
end else
  $UN.cast{cPtr0(a)}(the_null_ptr)
// end of [if]
//
end // end of [linheap_getmin_ref]

(* ****** ****** *)

implement{a}
linheap_delmin
  (hp0, res) = let
//
fun loop (
  nxs_ref: Ptr1, nx0_ref: Ptr1, nx0: g2node1 (a)
) : g2node1 (a) = let
  val nxs =
    $UN.ptr1_get<g2node0(a)> (nxs_ref)
  val iscons = gnodelst_is_cons (nxs)
in
//
if iscons then let
  val nx = nxs
  val nx_ref = nxs_ref
  val nxs_ref = gnode_getref_next (nx)
  val nxs_ref = cptr2ptr (nxs_ref)
  val sgn = gnode_compare01<a> (nx0, nx)
in
  if sgn <= 0 then
    loop (nxs_ref, nx0_ref, nx0) else loop (nxs_ref, nx_ref, nx)
  // end of [if]
end else let
  val () = $UN.ptr1_set<g2node0(a)> (nx0_ref, gnode_get_next (nx0))
in
  nx0
end // end of [if]
//
end // end of [loop]
//
fun auxrev
(
  nxs: g2node0 (a)
) : g2node0 (a) = let
//
fun loop (
  nxs: g2node0 (a), res: g2node0 (a)
) : g2node0 (a) = let
  val isnot = gnode_isnot_null (nxs)
in
//
if isnot then let
  val nx = nxs
  val () = g2node_set_parent_null (nx)
  val nxs = gnode_get_next (nx)
in
  loop (nxs, g2nodelst_cons (nx, res))
end else res // end of [if]
//
end // end of [loop]
//
in
  $effmask_all (loop (nxs, gnode_null ()))
end // end of [auxrev]
//
var nxs0 =
  $UN.castvwtp0{g2node0(a)}(hp0)
val iscons = gnodelst_is_cons (nxs0)
//
in
//
if iscons then let
  val nx0 = nxs0
  val nx0_ref = addr@(nxs0)
  val nxs_ref = gnode_getref_next (nx0)
  val nxs_ref = cptr2ptr (nxs_ref)
//
  val nx_min = loop (nxs_ref, nx0_ref, nx0)
//
  val nxs_min = g2node_get_children (nx_min)
  val ((*void*)) = g2node_free_elt (nx_min, res)
//
  val nxs_min = auxrev (nxs_min)
  val nxs0 = merge_gnodelst_gnodelst<a> (nxs0, nxs_min)
  val () = hp0 := $UN.castvwtp0{heap(a)}(nxs0)
//
  prval () = opt_some{a}(res)
//
in
  true
end else let
//
  val () = hp0 := $UN.castvwtp0{heap(a)}(the_null_ptr)
//
  prval () = opt_none{a}(res)
//
in
  false
end // end of [if]
//
end // end of [linheap_delmin]

(* ****** ****** *)

implement
{a}(*tmp*)
linheap_merge
  (hp1, hp2) = let
  val nxs1 = $UN.castvwtp0{g2node0(a)}(hp1)
  val nxs2 = $UN.castvwtp0{g2node0(a)}(hp2)
  val nxs12 = merge_gnodelst_gnodelst<a> (nxs1, nxs2)
in
  $UN.castvwtp0{heap(a)}(nxs12)
end // end of [linheap_merge]

(* ****** ****** *)

implement
{a}(*tmp*)
linheap_freelin
  (hp) = let
//
fun auxfree
(
  nx: g2node0(a)
) : void = let
//
val isnot = gnode_isnot_null (nx)
//
in
//
if isnot then let
  val nxs = g2node_get_children (nx)
  val ((*void*)) = auxfree (nxs)
  val nx2 = gnode_get_next (nx)
  val cp = gnode_getref_elt (nx)
  val (pf, fpf | p) = $UN.cptr_vtake (cp)
  val ((*void*)) = linheap_freelin$clear<a> (!p)
  val ((*void*)) = $extfcall (void, "ATS_MFREE", $UN.castvwtp0{ptr}((pf, fpf | p)))
in
  auxfree (nx2)
end else () // end of [if]
//
end // end of [auxfree]
//
in
  $effmask_all (auxfree ($UN.castvwtp0{g2node0(a)}(hp)))
end // end of [linheap_freelin]

(* ****** ****** *)
//
// HX: functions for processing g2nodes
//
(* ****** ****** *)

vtypedef
hpnode_struct
(
  elt: vt0p
) = // sknode_struct
@{
  elt= elt, rank= int, next= ptr, parent= ptr, children= ptr
} (* end of [hpnode_struct] *)

(* ****** ****** *)

extern
castfn
__cast_hpnode
  {a:vt0p}{l:agz}
(
  nx: g2node (INV(a), l)
) :<> [l:addr]
(
  hpnode_struct (a) @ l
, hpnode_struct (a) @ l -<lin,prf> void
| ptr l
) // end of [__cast_hpnode]

(* ****** ****** *)

implement{a}
g2node_make_elt (x) = let
//
val (
  pf, pfgc | p
) = ptr_alloc<hpnode_struct(a)> ()
//
val () = p->elt := x
//
in
  $UN.castvwtp0{g2node1(a)}((pf, pfgc | p))
end // end of [g2node_make_elt]

(* ****** ****** *)

implement{a}
g2node_free (nx) =
(
  $extfcall (void, "ATS_MFREE", $UN.cast{ptr}(nx))
) // end of [g2node_free]

(* ****** ****** *)

implement{a}
g2node_free_elt (nx, res) = let
//
val (pf, fpf | p) = __cast_hpnode (nx)
val () = res := p->elt
//
in
  $extfcall (void, "ATS_MFREE", $UN.castvwtp0{ptr}((pf, fpf | p)))
end // end of [g2node_free_elt]

(* ****** ****** *)

implement{a}
g2node_get_rank
  (nx) = r where
{
//
val (pf, fpf | p) = __cast_hpnode (nx)
val r = p->rank
prval () = fpf (pf)
} // end of [g2node_get_rank]

implement{a}
g2node_set_rank (nx, r) = let
//
val (pf, fpf | p) = __cast_hpnode (nx)
val () = p->rank := r
prval () = fpf (pf)
//
in
  // nothing
end // end of [g2node_set_rank]

(* ****** ****** *)

implement{a}
g2node_get_parent (nx) = let
val (pf, fpf | p) = __cast_hpnode (nx)
val p_parent = p->parent
prval () = fpf (pf)
//
in
  $UN.cast{g2node0(a)}(p_parent)
end // end of [g2node_get_parent]

implement{a}
g2node_set_parent (nx, nx2) = let
val (pf, fpf | p) = __cast_hpnode (nx)
val () = p->parent := $UN.cast{ptr}(nx2)
prval () = fpf (pf)
//
in
  // nothing
end // end of [g2node_set_parent]

implement{a}
g2node_set_parent_null (nx) = let
val (pf, fpf | p) = __cast_hpnode (nx)
val () = p->parent := $UN.cast{ptr}(the_null_ptr)
prval () = fpf (pf)
//
in
  // nothing
end // end of [g2node_set_parent_null]

(* ****** ****** *)

implement{a}
g2node_get_children (nx) = let
val (pf, fpf | p) = __cast_hpnode (nx)
val p_children = p->children
prval () = fpf (pf)
//
in
  $UN.cast{g2node0(a)}(p_children)
end // end of [g2node_get_children]

implement{a}
g2node_set_children (nx, nx2) = let
val (pf, fpf | p) = __cast_hpnode (nx)
val () = p->children := $UN.cast{ptr}(nx2)
prval () = fpf (pf)
//
in
  // nothing
end // end of [g2node_set_children]

implement{a}
g2node_set_children_null (nx) = let
val (pf, fpf | p) = __cast_hpnode (nx)
val () = p->children := $UN.cast{ptr}(the_null_ptr)
prval () = fpf (pf)
//
in
  // nothing
end // end of [g2node_set_children_null]

(* ****** ****** *)

implement{a}
g2nodelst_cons (nx, nxs) =
  let val () = gnode_link10 (nx, nxs) in nx end
// end of [g2nodelst_cons]

(* ****** ****** *)

implement(a)
gnode_getref_elt<mytkind><a>
  (nx) = let
val (pf, fpf | p) = __cast_hpnode (nx)
val p_elt = addr@(p->elt)
prval () = fpf (pf)
//
in
  $UN.cast{cPtr1(a)}(p_elt)
end // end of [gnode_getref_elt]

(* ****** ****** *)

implement(a)
gnode_getref_next<mytkind><a>
  (nx) = let
val (pf, fpf | p) = __cast_hpnode (nx)
val p_next = addr@(p->next)
prval () = fpf (pf)
//
in
  $UN.cast{cPtr1(g2node0(a))}(p_next)
end // end of [g2node_getref_next]

(* ****** ****** *)

implement(a)
gnode_link10<mytkind><a>
  (nx1, nx2) = gnode_set_next (nx1, nx2)
// end of [gnode_link10]

implement(a)
gnode_link11<mytkind><a>
  (nx1, nx2) = gnode_set_next (nx1, nx2)
// end of [gnode_link11]

(* ****** ****** *)

(* linheap_binomial2.dats *)