~ubuntu-branches/ubuntu/oneiric/spass/oneiric

« back to all changes in this revision

Viewing changes to SPASS/vector.c

  • Committer: Bazaar Package Importer
  • Author(s): Roland Stigge
  • Date: 2010-06-27 18:59:28 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100627185928-kdjuqghv04rxyqmc
Tags: 3.7-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************************/
 
2
/* ********************************************************** */
 
3
/* *                                                        * */
 
4
/* *             GLOBAL SYSTEM VECTOR                       * */
 
5
/* *                                                        * */
 
6
/* *  $Module:   VECTOR                                     * */ 
 
7
/* *                                                        * */
 
8
/* *  Copyright (C) 1996, 2000, 2001 MPI fuer Informatik    * */
 
9
/* *                                                        * */
 
10
/* *  This program is free software; you can redistribute   * */
 
11
/* *  it and/or modify it under the terms of the FreeBSD    * */
 
12
/* *  Licence.                                              * */
 
13
/* *                                                        * */
 
14
/* *  This program is distributed in the hope that it will  * */
 
15
/* *  be useful, but WITHOUT ANY WARRANTY; without even     * */
 
16
/* *  the implied warranty of MERCHANTABILITY or FITNESS    * */
 
17
/* *  FOR A PARTICULAR PURPOSE.  See the LICENCE file       * */ 
 
18
/* *  for more details.                                     * */
 
19
/* *                                                        * */
 
20
/* *                                                        * */
 
21
/* $Revision: 1.2 $                                     * */
 
22
/* $State: Exp $                                            * */
 
23
/* $Date: 2010-02-22 14:10:00 $                             * */
 
24
/* $Author: weidenb $                                         * */
 
25
/* *                                                        * */
 
26
/* *             Contact:                                   * */
 
27
/* *             Christoph Weidenbach                       * */
 
28
/* *             MPI fuer Informatik                        * */
 
29
/* *             Stuhlsatzenhausweg 85                      * */
 
30
/* *             66123 Saarbruecken                         * */
 
31
/* *             Email: spass@mpi-inf.mpg.de                * */
 
32
/* *             Germany                                    * */
 
33
/* *                                                        * */
 
34
/* ********************************************************** */
 
35
/**************************************************************/
 
36
 
 
37
 
 
38
/* $RCSfile: vector.c,v $ */
 
39
 
 
40
#include "vector.h"
 
41
 
 
42
/**************************************************************/
 
43
/* Global Variables                                           */
 
44
/**************************************************************/
 
45
 
 
46
VECTOR vec_VECTOR;
 
47
int    vec_MAX;
 
48
 
 
49
 
 
50
/**************************************************************/
 
51
/* Functions                                                  */
 
52
/**************************************************************/
 
53
 
 
54
void vec_Swap(int i, int j)
 
55
/**********************************************************
 
56
  INPUT:   Two integers i and j which designate the i-th and
 
57
           the j-th cell of the vector.
 
58
  RETURNS: None.
 
59
  CAUTION: The values in the i-th and the j-th cell in the
 
60
            vector are interchanged.
 
61
********************************************************/
 
62
{
 
63
  POINTER help;
 
64
 
 
65
  help  = vec_GetNth(i);
 
66
  vec_PutNth(i, vec_GetNth(j));
 
67
  vec_PutNth(j, help);
 
68
 
 
69
}
 
70
 
 
71
 
 
72
void vec_PrintSel(int beg, int end, void (*ElementPrint)(POINTER))
 
73
/**********************************************************
 
74
  INPUT:   An int for the start position, an int for
 
75
           the end position and a print function for
 
76
           elements.
 
77
  RETURNS: None.
 
78
  EFFECT:  Writes the vector from beg to end to stdout.
 
79
  CAUTION: None.
 
80
********************************************************/
 
81
{
 
82
  int i;
 
83
 
 
84
  if (vec_ActMax() > 0) {
 
85
    for (i = beg; i < end; i++){
 
86
      printf("Entry %d:\t",i);
 
87
      ElementPrint(vec_GetNth(i));
 
88
      putchar('\n');
 
89
    }
 
90
  } else
 
91
    puts("Vector is empty");
 
92
}
 
93
 
 
94
 
 
95
void vec_PrintAll(void (*ElementPrint)(POINTER))
 
96
/**********************************************************
 
97
  INPUT:   A print function for the elements of the vector.
 
98
  RETURNS: None.
 
99
  EFFECT:  Writes the vector to stdout.
 
100
  CAUTION: None.
 
101
********************************************************/
 
102
{
 
103
  int i;
 
104
 
 
105
  if (vec_ActMax() > 0) {
 
106
    for (i = 0; i < vec_ActMax(); i++) {
 
107
      printf("Entry %d:\t", i);
 
108
      ElementPrint(vec_GetNth(i));
 
109
      putchar('\n');
 
110
    }
 
111
  } else
 
112
    puts("Vector is empty");
 
113
}