📄 sarray.c
字号:
/*-------------------------------------------------------------------- * cutting - compute palanr cuttings * Copyright (C) 1998 Sariel Har-Peled * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA.\*--------------------------------------------------------------------*//*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* * array.c - * Implement a templated array\*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <assert.h>#include "_generic.h"#include "real.h"#include "sarray.h"/*========================================================================= * Static Debug Variables*=========================================================================*///SOURCE__FILE;/*========================================================================= * Start of Code*=========================================================================*/GLOBAL int searchArrayEntry( const void * ptr, int size, int numEnt, const void * var ){ int ind; for ( ind = 0; ind < numEnt; ind++ ) { if ( memcmp( ptr, var, size ) == 0 ) { return ind; } ptr = ADDR( (void *)ptr, size ); } return -1;}GLOBAL int searchTableEntry( const void * ptr, int localOffset, int localSize, int size, int numEnt, const void * var ){ int ind; for ( ind = 0; ind < numEnt; ind++ ) { if ( memcmp( ADDR( (void *)ptr, localOffset ), var, localSize ) == 0 ) { return ind; } ptr = ADDR( (void *)ptr, size ); } return -1;}GLOBAL int calcEntriesNum( void * _ptr, int size ){ int entriesNum, ind; char * ptr; bool fZero; ptr = (char *)_ptr; entriesNum = 0; do { fZero = true; for ( ind = 0; ind < size; ind++ ) if ( ptr[ ind ] ) { fZero = false; break; } if ( fZero ) return entriesNum; entriesNum++; ptr = ADDR( ptr, size ); } while ( 1 );}/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* * * array.c - End of File\*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -