Skip to main content

i need to split larger set list into samllersmaller chunks

added 112 characters in body
Source Link
Santanu Boral
  • 36.2k
  • 8
  • 45
  • 72

i have a requirement, where i am holding list(1000) of email address into one set, and with that i need to split them in to 100 in each sublist and make queryString need to perform sosl query.

set nms= new set(); string str; integer setindex=0; for(integer i=0;i<100;i++) { nms.add(i); }

system.debug('set==>'+nms.size());

set temp= new set(); for(integer i=0;i<nms.size()/10;i++) {

 set<integer> nms= new set<integer>();
string str;
integer setindex=0;
for(integer i=0;i<100;i++)
{
    nms.add(i);
}

system.debug('set==>'+nms.size());

set<integer> temp= new set<integer>();
for(integer i=0;i<nms.size()/10;i++)
{
    
    for(integer j=0;j<30;j++ )
    { 
        str=str +string.valueOf(j)+' or ';
        setindex++;
        //sosl
        
    }
    
   if(setindex== nms.size())
       break;
   system.debug('set==>'+str);
    
}

if(setindex== nms.size()) break; system.debug('set==>'+str);

} can can any one help me fix this issue.

Thanks

i have a requirement, where i am holding list(1000) of email address into one set, and with that i need to split them in to 100 in each sublist and make queryString need to perform sosl query.

set nms= new set(); string str; integer setindex=0; for(integer i=0;i<100;i++) { nms.add(i); }

system.debug('set==>'+nms.size());

set temp= new set(); for(integer i=0;i<nms.size()/10;i++) {

for(integer j=0;j<30;j++ )
{ 
    str=str +string.valueOf(j)+' or ';
    setindex++;
    //sosl
    
}

if(setindex== nms.size()) break; system.debug('set==>'+str);

} can any one help me fix this issue.

Thanks

i have a requirement, where i am holding list(1000) of email address into one set, and with that i need to split them in to 100 in each sublist and make queryString need to perform sosl query.

 set<integer> nms= new set<integer>();
string str;
integer setindex=0;
for(integer i=0;i<100;i++)
{
    nms.add(i);
}

system.debug('set==>'+nms.size());

set<integer> temp= new set<integer>();
for(integer i=0;i<nms.size()/10;i++)
{
    
    for(integer j=0;j<30;j++ )
    { 
        str=str +string.valueOf(j)+' or ';
        setindex++;
        //sosl
        
    }
    
   if(setindex== nms.size())
       break;
   system.debug('set==>'+str);
    
}

can any one help me fix this issue.

Thanks

Source Link
Vijay
  • 33
  • 1
  • 5

i need to split larger set list into samller chunks

i have a requirement, where i am holding list(1000) of email address into one set, and with that i need to split them in to 100 in each sublist and make queryString need to perform sosl query.

set nms= new set(); string str; integer setindex=0; for(integer i=0;i<100;i++) { nms.add(i); }

system.debug('set==>'+nms.size());

set temp= new set(); for(integer i=0;i<nms.size()/10;i++) {

for(integer j=0;j<30;j++ )
{ 
    str=str +string.valueOf(j)+' or ';
    setindex++;
    //sosl
    
}

if(setindex== nms.size()) break; system.debug('set==>'+str);

} can any one help me fix this issue.

Thanks