Answers for "remove from set javascript"

2

set.delete

// erasing from set
#include <iostream>
#include <set>

int main ()
{
  std::set<int> myset;
  std::set<int>::iterator it;

  // insert some values:
  for (int i=1; i<10; i++) myset.insert(i*10);  // 10 20 30 40 50 60 70 80 90

  it = myset.begin();
  ++it;                                         // "it" points now to 20

  myset.erase (it);

  myset.erase (40);

  it = myset.find (60);
  myset.erase (it, myset.end());

  std::cout << "myset contains:";
  for (it=myset.begin(); it!=myset.end(); ++it)
    std::cout << ' ' << *it;
  std::cout << '\n';

  return 0;
}
Posted by: Guest on August-26-2020
1

remove from set javascript

// Create new set
const animals = new Set();

// Add to set
animals.add('cat');
animals.add('dog');

// Remove from set
animals.delete('cat'); // returns true
animals.delete('dog'); // returns true
animals.delete('horse'); // returns false
Posted by: Guest on September-08-2020

Code answers related to "remove from set javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language