Hi All, I need some smart way to accomplish this task in C# (.net 1.0)
Appreciate your inputs!!
==================================
Input ArrayList:
2,3,4,20
1,2,2
2
2,2,2
1,2,3,4
1,1
null
expected oututs:
Bundle Count=1 and the bundle will contain 2,3,4,20
Bundle Count=3 Bundle#1 wil contain 1 Bundle#2 will contain 2 and Bundle#3
will cotain 2
Bundle Count=1 Bundle#1 will contain 2
Bundle Count=3 Bundle#1 wil contain 2 Bundle#2 will contain 2 and Bundle#3
will cotain 2
Bundle Count=2 Bundle#1 wil contain 1 Bundle#2 will contain 2 ,3,4
{formatted with,}
Bundle Count =2 Bundle#1 wil contain 1 Bundle#2 will contain 1
Null
............
================================== 6 1229
The answers in the other thread will do what you are after. Though seeing
this it was a poor explanation in your original post. And this one isn't too
clear either. So you have a load of array lists each with data and you want
them to be broken up into new arrays of data? Or do you want them broken up
into individual strings? strings arrays? What?
Anyway this is a guide, you do need to apply some coding skill to match your
exact requirement as no one helping knows the context of all this, so:
1) Loop your input array list
2) Get the value of an array slot and check if it is 2 or 1
3) if 2 or 1 create new array, string array whatever it is you want it as,
store it in the array
4) go to next slot, if it is not a 2 or 1 append to the created array in
step 3.
5) If it is a 2 or 1 store the array created and make a new one, store the
2/1 and repeat.
Now do that for every array list being passed in. That will work. Up to you
to apply it. If you struggle to apply it then try and post your code
attempt.
"Vai2000" <no****@microsoft.comwrote in message
news:ue*************@TK2MSFTNGP06.phx.gbl...
Hi All, I need some smart way to accomplish this task in C# (.net 1.0)
Appreciate your inputs!!
==================================
Input ArrayList:
2,3,4,20
1,2,2
2
2,2,2
1,2,3,4
1,1
null
expected oututs:
Bundle Count=1 and the bundle will contain 2,3,4,20
Bundle Count=3 Bundle#1 wil contain 1 Bundle#2 will contain 2 and Bundle#3
will cotain 2
Bundle Count=1 Bundle#1 will contain 2
Bundle Count=3 Bundle#1 wil contain 2 Bundle#2 will contain 2 and Bundle#3
will cotain 2
Bundle Count=2 Bundle#1 wil contain 1 Bundle#2 will contain 2 ,3,4
{formatted with,}
Bundle Count =2 Bundle#1 wil contain 1 Bundle#2 will contain 1
Null
...........
==================================
I am looking for a smart solution, I have already done it but its not a very
smart solution!!
Answers to your questions:
1. The ArrayList stores strings inside it.....
so what I showed below are contents of the arrayList...
I need tight routine!!!
TIA
"Daniel" <no****@pokercat.co.ukwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
The answers in the other thread will do what you are after. Though seeing
this it was a poor explanation in your original post. And this one isn't
too
clear either. So you have a load of array lists each with data and you
want
them to be broken up into new arrays of data? Or do you want them broken
up
into individual strings? strings arrays? What?
Anyway this is a guide, you do need to apply some coding skill to match
your
exact requirement as no one helping knows the context of all this, so:
1) Loop your input array list
2) Get the value of an array slot and check if it is 2 or 1
3) if 2 or 1 create new array, string array whatever it is you want it as,
store it in the array
4) go to next slot, if it is not a 2 or 1 append to the created array in
step 3.
5) If it is a 2 or 1 store the array created and make a new one, store the
2/1 and repeat.
Now do that for every array list being passed in. That will work. Up to
you
to apply it. If you struggle to apply it then try and post your code
attempt.
"Vai2000" <no****@microsoft.comwrote in message
news:ue*************@TK2MSFTNGP06.phx.gbl...
Hi All, I need some smart way to accomplish this task in C# (.net 1.0)
Appreciate your inputs!!
==================================
Input ArrayList:
2,3,4,20
1,2,2
2
2,2,2
1,2,3,4
1,1
null
expected oututs:
Bundle Count=1 and the bundle will contain 2,3,4,20
Bundle Count=3 Bundle#1 wil contain 1 Bundle#2 will contain 2 and
Bundle#3
will cotain 2
Bundle Count=1 Bundle#1 will contain 2
Bundle Count=3 Bundle#1 wil contain 2 Bundle#2 will contain 2 and
Bundle#3
will cotain 2
Bundle Count=2 Bundle#1 wil contain 1 Bundle#2 will contain 2 ,3,4
{formatted with,}
Bundle Count =2 Bundle#1 wil contain 1 Bundle#2 will contain 1
Null
...........
==================================
Hi,
What exactly was not smart about the solution presented in the other
thread?
Brian
On Jan 29, 1:35 pm, "Vai2000" <nos...@microsoft.comwrote:
I am looking for a smart solution, I have already done it but its not a very
smart solution!!
Answers to your questions:
1. The ArrayList stores strings inside it.....
so what I showed below are contents of the arrayList...
I need tight routine!!!
TIA
Sadly No! Dont worry about it...I finally wrote it myself
===================================
for(int idx=0;idx<alNonBundle.Count;idx++)
{
str=alNonBundle[idx];
if(str.Equals("2") || str.Equals("1"))
{
pos=idx;
CopyArray(lastpos,pos,alNonBundle);
lastpos=pos;
}
}
void CopyArray(int spos,int epos,ArrayList al)
{
string []arr=new string[epos-spos];
al.CopyTo(spos,arr,0,epos-spos);
}
"Brian Gideon" <br*********@yahoo.comwrote in message
news:11**********************@l53g2000cwa.googlegr oups.com...
Hi,
What exactly was not smart about the solution presented in the other
thread?
Brian
On Jan 29, 1:35 pm, "Vai2000" <nos...@microsoft.comwrote:
I am looking for a smart solution, I have already done it but its not a
very
smart solution!!
Answers to your questions:
1. The ArrayList stores strings inside it.....
so what I showed below are contents of the arrayList...
I need tight routine!!!
TIA
Hi,
Are you sure that's right? That code doesn't produce any side
effects. Seems like the following is more of what you want.
public IList Partition(IList input)
{
IList output = new ArrayList();
IList bundle = new ArrayList();
foreach (string item in input)
{
if (bundle.Count 0 && (item == "1" || item == "2"))
{
output.Add(bundle);
bundle = new ArrayList();
}
bundle.Add(item);
}
output.Add(bundle);
return output;
}
Brian
On Jan 29, 2:31 pm, "Vai2000" <nos...@microsoft.comwrote:
Sadly No! Dont worry about it...I finally wrote it myself
===================================
for(int idx=0;idx<alNonBundle.Count;idx++)
{
str=alNonBundle[idx];
if(str.Equals("2") || str.Equals("1"))
{
pos=idx;
CopyArray(lastpos,pos,alNonBundle);
lastpos=pos;
}
}void CopyArray(int spos,int epos,ArrayList al)
{
string []arr=new string[epos-spos];
al.CopyTo(spos,arr,0,epos-spos);
}
You actually tried? For yourself! Gasp! Surely not..... Word of advice and
friendly tip. Don't use exclamation marks when asking for help, try not to
be rude about help you are given and be respectful of others.
"Vai2000" <no****@microsoft.comwrote in message
news:%2******************@TK2MSFTNGP03.phx.gbl...
Sadly No! Dont worry about it...I finally wrote it myself
===================================
for(int idx=0;idx<alNonBundle.Count;idx++)
{
str=alNonBundle[idx];
if(str.Equals("2") || str.Equals("1"))
{
pos=idx;
CopyArray(lastpos,pos,alNonBundle);
lastpos=pos;
}
}
void CopyArray(int spos,int epos,ArrayList al)
{
string []arr=new string[epos-spos];
al.CopyTo(spos,arr,0,epos-spos);
}
"Brian Gideon" <br*********@yahoo.comwrote in message
news:11**********************@l53g2000cwa.googlegr oups.com...
>Hi,
What exactly was not smart about the solution presented in the other thread?
Brian
On Jan 29, 1:35 pm, "Vai2000" <nos...@microsoft.comwrote:
I am looking for a smart solution, I have already done it but its not a
very
smart solution!!
Answers to your questions:
1. The ArrayList stores strings inside it.....
so what I showed below are contents of the arrayList...
I need tight routine!!!
TIA This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dave Benjamin |
last post by:
Hey all,
I just realized you can very easily implement a sequence grouping function
using Python 2.3's fancy slicing support:
def group(values, size):
return map(None, * for i in...
|
by: Christian Stigen Larsen |
last post by:
Consider the following:
class parent {
public:
virtual void print() {
printf("Parent\n");
}
};
class child : public parent {
|
by: Shankar |
last post by:
Hello,
We have a smart pointer class which provides the dereference
operator -> to access the underlying object pointer. Now, we have a new
requirement where a different type of object (e.g from...
|
by: Bryan Olson |
last post by:
I recently wrote a module supporting value-shared slicing. I
don't know if this functionality already existed somewhere, but
I think it's useful enough that other Pythoners might want it,
so here...
|
by: Neal Coombes |
last post by:
Posted to comp.lang.c++.moderated with little response. Hoping for
better from the unmoderated groups:
-------- Original Message --------
Subject: Return appropriately by value, (smart)...
|
by: jbperez808 |
last post by:
>>> rs='AUGCUAGACGUGGAGUAG'
>>> rs='GAG'
Traceback (most recent call last):
File "<pyshell#119>", line 1, in ?
rs='GAG'
TypeError: object doesn't support slice assignment
You can't assign to...
|
by: baibaichen |
last post by:
i have written some code to verify how to disable slicing copy
according C++ Gotchas item 30
the follow is my class hierarchy, and note that B is abstract class!!
class B
{
public:
explicit...
|
by: AlesD |
last post by:
Hello,
I have problem that when I use std::list<MyClassand then store
various subclasses of MyClass in that list (or any other STL container)
the instances get sliced.
I have read FAQ: ' What...
|
by: Vai2000 |
last post by:
Hi All, I am looking for a smart solution to accomplish this task (.net 1.0)
Appreciate your input
I have a group of numbers in an arrayList
2,3,5,2,1,2,2
I need to output them into groups of...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |