# Remove 3 elements from vtkStringArray

**URL:** https://discourse.vtk.org/t/remove-3-elements-from-vtkstringarray/3317
**Category:** Support
**Created:** [May 15, 2020, 4:19pm UTC](https://discourse.vtk.org/t/remove-3-elements-from-vtkstringarray/3317 "2020-05-15T16:19:46Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![flaviu2](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.vtk.org/u/flaviu2)
#### Post date: [May 15, 2020, 4:19pm UTC](https://discourse.vtk.org/t/remove-3-elements-from-vtkstringarray/3317/1 "2020-05-15T16:19:46Z")

</div>

Is there any way to remove 3 elements from a vtkStringArray without clean up the array and load all elements except those 3 ?

And, how can I delete all elements from array without Delete method and create another one ?

I don’t see any helping method here: [https://vtk.org/doc/nightly/html/classvtkStringArray.html](https://vtk.org/doc/nightly/html/classvtkStringArray.html)

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [May 16, 2020, 8:56pm UTC](https://discourse.vtk.org/t/remove-3-elements-from-vtkstringarray/3317/2 "2020-05-16T20:56:47Z")

</div>

Hmm… I also took a look at its iterator ([https://vtk.org/doc/nightly/html/classvtkArrayIterator.html](https://vtk.org/doc/nightly/html/classvtkArrayIterator.html)) for a possible element removal method, bit it doesn’t seem to have one too. I didn’t find any way to remove elements from it without resorting to a hack (or without creating a new object). From its API it seems to be an older style container object without some of the features of present day STL containers (e.g. `std::vector()`) like sorting or removing individual elements.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [May 16, 2020, 10:34pm UTC](https://discourse.vtk.org/t/remove-3-elements-from-vtkstringarray/3317/3 "2020-05-16T22:34:31Z")

</div>

To remove items from an array (just 3 or all of them), you can set the number of values.

If you want to update the content of an entire array at once then you can use DeepCopy.

VTK API documentation is pretty good, but if something is not clear you can check out the thousands of tests and examples and you can also find nice description of most important concepts in the VTK textbook.
