c++ function to convert a linear list to circular list


 
Thread Tools Search this Thread
Top Forums Programming c++ function to convert a linear list to circular list
Prev   Next
# 1  
Old 08-25-2010
Question c++ function to convert a linear list to circular list

hi all,

i need a c++ function which converts a linear list to circular.
presently i am working with two files. i.e., one linear list file. and one circular list file to do some operations. i thought it will be helpful if there is a function that converts a linear list to circular n undo the same whenever required.....
Please help me........
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert list of numbers to text range

Hi, I'd like to take a list of numbers (with a prefix) and convert to a range, for example: cn001 cn004 cn016 cn017 cn018 cn019 cn020 cn021 cn031 cn032 cn038 cn042 cn043 cn044 cn045 (5 Replies)
Discussion started by: chrissycc
5 Replies

2. Shell Programming and Scripting

Convert a two-column list into a csv

Hi experts, I have a very large (1.5M lines), sorted but unstructured list that looks like this: process_nameA valueA process_nameA valueA ... process_nameB valueB process_nameB valueB ... process_nameN valueN I'd like to turn this into a csv. The values are all... (4 Replies)
Discussion started by: abercrom
4 Replies

3. UNIX for Dummies Questions & Answers

How convert space separated list to matched columns?

Hi I have been racking my (limited) brains to get this to work without success I have a file output which is a list of lists - ie a single column of data that is separated by space into sub lists below - I need to both split this so that each list is in a separate column (eg tab or semicolon... (8 Replies)
Discussion started by: Manchesterpaul
8 Replies

4. Shell Programming and Scripting

Convert a list of word/terms into their Regexp representation

Ok this might sound pretty weird but here is the request. Running on a linux system in bash or Perl (i really don't know perl but the end user has a few pearl script already) Start File looks something like this (4000 entries) TEST PLAN T//TF T-TF TEST (T) Hacker ... I am thinking about... (3 Replies)
Discussion started by: oly_r
3 Replies

5. Shell Programming and Scripting

Script to convert row to list

Hello, I have data which is basically a set of rows in which names having the same homophonic values are stored. I want to convert the data into lines such that the first word of the database is treated as the anchor and each subsequent word is appended to it with a column. An example... (5 Replies)
Discussion started by: gimley
5 Replies

6. Shell Programming and Scripting

convert list in a command

Hello, i would make a script that generate SWITCH commands to create zone in a SAN, i have this file: ## zone:z_CGBVMH1_FC0_to_EVA1_CTRL_A_1 p_CGBVMH1_FC0; p_EVA1_CTRL_A_1 ## zone:z_CGBVMH1_FC0_to_EVA1_CTRL_B_1 p_CGBVMH1_FC0; p_EVA1_CTRL_B_1 ## zone:z_CGBVMH1_FC2_to_EVA1_CTRL_A_1... (2 Replies)
Discussion started by: alen192
2 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. Programming

Linear linked list node delete

Given an in-between(any node not at the start and end of the linked list) node within a singly linear linked list, how to delete that node, when head pointer of list is not given? (13 Replies)
Discussion started by: rupeshkp728
13 Replies

9. Shell Programming and Scripting

Convert perl qw list to text file list?

Does anyone have a good example? I am having trouble looping.. Thanks (1 Reply)
Discussion started by: mrlayance
1 Replies

10. Shell Programming and Scripting

Splitting a list @list by space delimiter so i can access it by using $list[0 ..1..2]

EDIT : This is for perl @data2 = grep(/$data/, @list_now); This gives me @data2 as Printing data2 11 testzone1 running /zones/testzone1 ***-*****-****-*****-***** native shared But I really cant access data2 by its individual elements. $data2 is the entire list, while $data,2,3...... (1 Reply)
Discussion started by: shriyer
1 Replies
Login or Register to Ask a Question
INSQUE(3)						     Linux Programmer's Manual							 INSQUE(3)

NAME
insque, remque - insert/remove an item from a queue SYNOPSIS
#include <search.h> void insque(void *elem, void *prev); void remque(void *elem); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): insque(), remque(): _SVID_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED DESCRIPTION
The insque() and remque() functions manipulate doubly-linked lists. Each element in the list is a structure of which the first two ele- ments are a forward and a backward pointer. The linked list may be linear (i.e., NULL forward pointer at the end of the list and NULL backward pointer at the start of the list) or circular. The insque() function inserts the element pointed to by elem immediately after the element pointed to by prev. If the list is linear, then the call insque(elem, NULL) can be used to insert the initial list element, and the call sets the forward and backward pointers of elem to NULL. If the list is circular, the caller should ensure that the forward and backward pointers of the first element are initialized to point to that element, and the prev argument of the insque() call should also point to the element. The remque() function removes the element pointed to by elem from the doubly-linked list. CONFORMING TO
POSIX.1-2001. NOTES
Traditionally (e.g., SunOS, Linux libc 4 and libc 5), the arguments of these functions were of type struct qelem *, defined as: struct qelem { struct qelem *q_forw; struct qelem *q_back; char q_data[1]; }; This is still what you will get if _GNU_SOURCE is defined before including <search.h>. The location of the prototypes for these functions differs among several versions of UNIX. The above is the POSIX version. Some systems place them in <string.h>. Linux libc4 and libc 5 placed them in <stdlib.h>. BUGS
In glibc 2.4 and earlier, it was not possible to specify prev as NULL. Consequently, to build a linear list, the caller had to build a list using an initial call that contained the first two elements of the list, with the forward and backward pointers in each element suit- ably initialized. EXAMPLE
The program below demonstrates the use of insque(). Here is an example run of the program: $ ./a.out -c a b c Traversing completed list: a b c That was a circular list Program source #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <search.h> struct element { struct element *forward; struct element *backward; char *name; }; static struct element * new_element(void) { struct element *e; e = malloc(sizeof(struct element)); if (e == NULL) { fprintf(stderr, "malloc() failed "); exit(EXIT_FAILURE); } return e; } int main(int argc, char *argv[]) { struct element *first, *elem, *prev; int circular, opt, errfnd; /* The "-c" command-line option can be used to specify that the list is circular */ errfnd = 0; circular = 0; while ((opt = getopt(argc, argv, "c")) != -1) { switch (opt) { case 'c': circular = 1; break; default: errfnd = 1; break; } } if (errfnd || optind >= argc) { fprintf(stderr, "Usage: %s [-c] string... ", argv[0]); exit(EXIT_FAILURE); } /* Create first element and place it in the linked list */ elem = new_element(); first = elem; elem->name = argv[optind]; if (circular) { elem->forward = elem; elem->backward = elem; insque(elem, elem); } else { insque(elem, NULL); } /* Add remaining command-line arguments as list elements */ while (++optind < argc) { prev = elem; elem = new_element(); elem->name = argv[optind]; insque(elem, prev); } /* Traverse the list from the start, printing element names */ printf("Traversing completed list: "); elem = first; do { printf(" %s ", elem->name); elem = elem->forward; } while (elem != NULL && elem != first); if (elem == first) printf("That was a circular list "); exit(EXIT_SUCCESS); } COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. 2010-09-09 INSQUE(3)