Edinburgh Speech Tools 2.4-release
EST_ilist_aux.cc
1/*************************************************************************/
2/* */
3/* Centre for Speech Technology Research */
4/* University of Edinburgh, UK */
5/* Copyright (c) 1994,1995,1996 */
6/* All Rights Reserved. */
7/* */
8/* Permission is hereby granted, free of charge, to use and distribute */
9/* this software and its documentation without restriction, including */
10/* without limitation the rights to use, copy, modify, merge, publish, */
11/* distribute, sublicense, and/or sell copies of this work, and to */
12/* permit persons to whom this work is furnished to do so, subject to */
13/* the following conditions: */
14/* 1. The code must retain the above copyright notice, this list of */
15/* conditions and the following disclaimer. */
16/* 2. Any modifications must be clearly marked as such. */
17/* 3. Original authors' names are not deleted. */
18/* 4. The authors' names are not used to endorse or promote products */
19/* derived from this software without specific prior written */
20/* permission. */
21/* */
22/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30/* THIS SOFTWARE. */
31/* */
32/*************************************************************************/
33/* Author : Paul Taylor, Simon King */
34/* Date : 1994-99 */
35/*-----------------------------------------------------------------------*/
36/* IList i/o utility functions */
37/* */
38/*=======================================================================*/
39
40#include <cstdio>
41#include <cctype>
42#include <cstdlib>
43#include <cstring>
44#include <fstream>
45#include <iostream>
46#include "EST_types.h"
47#include "EST_String.h"
48#include "EST_Pathname.h"
49#include "EST_string_aux.h"
50#include "EST_cutils.h"
51#include "EST_Token.h"
52
53int ilist_member(const EST_IList &l,int i)
54{
55 EST_Litem *p;
56 for (p = l.head(); p != 0; p = p->next())
57 if (l.item(p) == i)
58 return TRUE;
59
60 return FALSE;
61}
62
63int ilist_index(const EST_IList &l,int i)
64{
65 EST_Litem *p;
66 int j=0;
67 for (p = l.head(); p != 0; p = p->next())
68 {
69 if (l.item(p) == i)
70 return j;
71 j++;
72 }
73
74 return -1;
75}
76
77
78void IList_to_IVector(EST_IList &l, EST_IVector &v)
79{
80 int len,i;
81
82 len = l.length();
83 v.resize(len);
84
85 //EST_TBI *p;
86 EST_Litem *p;
87 for (p = l.head(),i=0; p != 0; p = p->next(),i++)
88 v[i] = l(p);
89}
90
91
92void IVector_to_IList(EST_IVector &v, EST_IList &l)
93{
94 int i;
95 l.clear();
96 for (i=0;i<v.length();i++)
97 l.append(v[i]);
98}
99
100
101int IVector_index(const EST_IVector &v,const int s)
102{
103 int i;
104 for(i=0;i<v.length();i++)
105 if(v(i) == s)
106 return i;
107
108 return -1;
109
110}
T & item(const EST_Litem *p)
Definition: EST_TList.h:133
void clear(void)
remove all items in list
Definition: EST_TList.h:239
void append(const T &item)
add item onto end of list
Definition: EST_TList.h:191
void resize(int n, int set=1)
resize vector
INLINE int length() const
number of items in vector.
Definition: EST_TVector.h:252