MCPcopy Create free account
hub / github.com/CytopiaTeam/Cytopia / RemoveRange

Method RemoveRange

external/as_add_on/scriptarray/scriptarray.cpp:653–679  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

651}
652
653void CScriptArray::RemoveRange(asUINT start, asUINT count)
654{
655 if (count == 0)
656 return;
657
658 if( buffer == 0 || start > buffer->numElements )
659 {
660 // If this is called from a script we raise a script exception
661 asIScriptContext *ctx = asGetActiveContext();
662 if (ctx)
663 ctx->SetException("Index out of bounds");
664 return;
665 }
666
667 // Cap count to the end of the array
668 if (start + count > buffer->numElements)
669 count = buffer->numElements - start;
670
671 // Destroy the elements that are being removed
672 Destruct(buffer, start, start + count);
673
674 // Compact the elements
675 // As objects in arrays of objects are not stored inline, it is safe to use memmove here
676 // since we're just copying the pointers to objects and not the actual objects.
677 memmove(buffer->data + start*elementSize, buffer->data + (start + count)*elementSize, (buffer->numElements - start - count)*elementSize);
678 buffer->numElements -= count;
679}
680
681// Internal
682void CScriptArray::Resize(int delta, asUINT at)

Callers 1

Calls 1

DestructFunction · 0.85

Tested by

no test coverage detected