FreeBASIC  0.91.0
array_core.c
Go to the documentation of this file.
1 /* dynamic arrays core */
2 
3 #include "fb.h"
4 
6  (
7  size_t dimensions,
8  const ssize_t *lboundTB,
9  const ssize_t *uboundTB
10  )
11 {
12  size_t i, elements;
13 
14  elements = (uboundTB[0] - lboundTB[0]) + 1;
15  for( i = 1; i < dimensions; i++ )
16  elements *= (uboundTB[i] - lboundTB[i]) + 1;
17 
18  return elements;
19 }
20 
21 ssize_t fb_hArrayCalcDiff
22  (
23  size_t dimensions,
24  const ssize_t *lboundTB,
25  const ssize_t *uboundTB
26  )
27 {
28  size_t i, elements;
29  ssize_t diff = 0;
30 
31  if( dimensions <= 0 )
32  return 0;
33 
34  for( i = 0; i < dimensions-1; i++ )
35  {
36  elements = (uboundTB[i+1] - lboundTB[i+1]) + 1;
37  diff = (diff + lboundTB[i]) * elements;
38  }
39 
40  diff += lboundTB[dimensions-1];
41 
42  return -diff;
43 }