Sponsored Content
Top Forums Programming Code review: recursion in circular array, reduce two functions to one? Post 303014907 by RudiC on Friday 23rd of March 2018 06:36:55 AM
Old 03-23-2018
That spec is beyond me. Mayhap others, with some assumptions on e.g. shell and data structure, find a sensible interpratation of what you write.

For an index not to exceed array boundaries the modulo operator has proven quite helpful.
This User Gave Thanks to RudiC For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can some review my code would be appreicated?

I am getting an error "ftpNotes.sh: syntax error at line 8 : `<<' unmatched" #!/bin/ksh PATH=/usr/sbin/:/usr/bin:/usr/ucb:/etc:/usr/local/bin:. cd $HOME if ;then if ; then echo 'DSC file already ftp to epm server' else ftp -n epmdev00 <<SCRIPT... (1 Reply)
Discussion started by: sibghat
1 Replies

2. Shell Programming and Scripting

Can someone review my code tell me where I am going wrong?

Started writing my code. my read input is not even asking nor working? And I get a EOF script error. echo "1) aragorn.domain.net" echo "2) marvel.domain.net" echo "3) athena.domain.net" echo "4) gandalf.domain.net" echo "5) griffin.domain.net" echo "What server would you like... (4 Replies)
Discussion started by: chrchcol
4 Replies

3. Shell Programming and Scripting

Tricky array substitution in functions

Hello, Please tell me if there is a better way to get the number of elements from an array that is passed to a function. This is what works on Solaris 8 (ksh) but it looks odd: loop_array() { array_name=$2 b1='\${\#' b2='}' nr_elements=`eval echo... (6 Replies)
Discussion started by: majormark
6 Replies

4. Programming

[ C ] multidemensional array pass to functions

Please excuse my ineptitude for a bit as I've been spoiled for the past few months with only writing perl code instead of C. So ok, I've been thinking about some code to change the crc32 values that are held within central directory headers of zip files. Because I'm lazy I decided to just... (3 Replies)
Discussion started by: VRoemer
3 Replies

5. Shell Programming and Scripting

How to reduce code.....

Hi All, Could some one help me to reduce the code... if then ./plist -m "$queuename" |grep $2|awk '{print $3}' >unlock.log elif then ./plist -m "$queuename" |grep $2|awk '{print $4}' >unlock.log else ./plist -m "$queuename" |grep $2|awk '{print $5}' >unlock.log . . . . ... (1 Reply)
Discussion started by: harshakusam
1 Replies

6. Shell Programming and Scripting

Passing array to functions in ksh script

Let me know if there is a way to pass array to a funtion in ksh script. function isPresent { typeset member member=$1 dbList=$2 echo '$1:' $1 echo '$2' $dbList The array will be at the second position....something like this isPresent 12 <array> if then echo... (3 Replies)
Discussion started by: prasperl
3 Replies

7. Programming

c++ code to check whether a list is circular or not

hi all, i need c++ code to check whether a list is circular or not... please help (8 Replies)
Discussion started by: vidyaj
8 Replies

8. Shell Programming and Scripting

Need help on Assigning a Array variable from Background Functions

I have a question on how can I assign a output of a function to a variable which is executed in background. Here is my example $ cat sample_program.sh #!/bin/ksh exec_func () { sleep 1 v=`expr $1 + 100` print $v } export OUT_ARR date for i in 1 2 do OUT_ARR=`exec_func $i` &... (1 Reply)
Discussion started by: mohan_kumarcs
1 Replies

9. Shell Programming and Scripting

Reduce the number of lines by using Array

I have the following code to count the number of how many times the name occurred in one file. The code is working fine and the output is exactly what I want. The problem is the real code has more than 50 names in function listname which cause function name to have more than 50 case ,and function... (14 Replies)
Discussion started by: samsan
14 Replies
SbPList(3)							       Coin								SbPList(3)

NAME
SbPList - The SbPList class is a container class for void pointers. SYNOPSIS
#include <Inventor/lists/SbPList.h> Inherited by SbIntList, SbStringList, SbVec3fList, SoActionMethodList, SoAuditorList [private], SoBaseList, SoDetailList, SoEngineOutputList, SoFieldList, SoPickedPointList, and SoTypeList. Public Member Functions SbPList (const int sizehint=DEFAULTSIZE) SbPList (const SbPList &l) ~SbPList () void copy (const SbPList &l) SbPList & operator= (const SbPList &l) void fit (void) void append (void *item) int find (void *item) const void insert (void *item, const int insertbefore) void removeItem (void *item) void remove (const int index) void removeFast (const int index) int getLength (void) const void truncate (const int length, const int fit=0) void ** getArrayPtr (const int start=0) const void *& operator[] (const int index) const int operator== (const SbPList &l) const int operator!= (const SbPList &l) const void * get (const int index) const void set (const int index, void *item) Protected Member Functions void expand (const int size) int getArraySize (void) const Detailed Description The SbPList class is a container class for void pointers. Constructor &; Destructor Documentation SbPList::SbPList (const intsizehint = DEFAULTSIZE) This constructor initializes the internal allocated size for the list to sizehint. Note that the list will still initially contain zero items. Default constructor. SbPList::SbPList (const SbPList &l) Copy constructor. SbPList::~SbPList () Destructor. Member Function Documentation void SbPList::copy (const SbPList &l) Make this list a copy of l. SbPList & SbPList::operator= (const SbPList &l) Assignment operator void SbPList::fit (void) Fit the allocated array exactly around the length of the list, descarding memory spent on unused pre-allocated array cells. You should normally not need or want to call this method, and it is only available for the sake of having the option to optimize memory usage for the unlikely event that you should throw around huge SbList objects within your application. void SbPList::append (void *item) [inline] Append item to the end of the list. Automatically allocates more items internally if needed. int SbPList::find (void *item) const Return index of first occurrence of item in the list, or -1 if item is not present. void SbPList::insert (void *item, const intinsertbefore) Insert item at index insertbefore. insertbefore should not be larger than the current number of items in the list. void SbPList::removeItem (void *item) Removes an item from the list. If there are several items with the same value, removes the item with the lowest index. void SbPList::remove (const intindex) Remove the item at index, moving all subsequent items downwards one place in the list. Reimplemented in SoAuditorList, SoChildList, and SoBaseList. void SbPList::removeFast (const intindex) [inline] Remove the item at index, moving the last item into its place and truncating the list. int SbPList::getLength (void) const [inline] Returns number of items in the list. Reimplemented in SoAuditorList. void SbPList::truncate (const intlength, const intfit = 0) [inline] Shorten the list to contain length elements, removing items from index length and onwards. If fit is non-zero, will also shrink the internal size of the allocated array. Note that this is much less efficient than not re-fitting the array size. Reimplemented in SoPickedPointList, and SoDetailList. void ** SbPList::getArrayPtr (const intstart = 0) const [inline] Returns pointer to a non-modifiable array of the lists elements. start specifies an index into the array. The caller is not responsible for freeing up the array, as it is just a pointer into the internal array used by the list. void *& SbPList::operator[] (const intindex) const [inline] Returns element at index. Will automatically expand the size of the internal array if index is outside the current bounds of the list. The values of any additional pointers are then set to NULL. Reimplemented in SoDetailList, SbVec3fList, SoBaseList, SbIntList, SbStringList, SoFieldList, SoPickedPointList, SoEngineOutputList, SoEngineList, SoNodeList, SoPathList, and SoTypeList. int SbPList::operator== (const SbPList &l) const Equality operator. Returns TRUE if this list and l are identical, containing the exact same ordered set of elements. SbBool SbPList::operator!= (const SbPList &l) const [inline] Inequality operator. Returns TRUE if this list and l are not equal. void * SbPList::get (const intindex) const [inline] Returns element at index. Does not expand array bounds if index is outside the list. Reimplemented in SoFieldList. void SbPList::set (const intindex, void *item) [inline] Index operator to set element at index. Does not expand array bounds if index is outside the list. void SbPList::expand (const intsize) [inline], [protected] Expand the list to contain size items. The new items added at the end have undefined value. int SbPList::getArraySize (void) const [inline], [protected] Return number of items there's allocated space for in the array. See also: getLength() Author Generated automatically by Doxygen for Coin from the source code. Version 3.1.3 Wed May 23 2012 SbPList(3)
All times are GMT -4. The time now is 08:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy