MCPcopy Create free account
hub / github.com/anjo76/angelscript / RemoveRange

Method RemoveRange

sdk/add_on/scriptarray/scriptarray.cpp:715–741  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

713}
714
715void CScriptArray::RemoveRange(asUINT start, asUINT count)
716{
717 if (count == 0)
718 return;
719
720 if( buffer == 0 || start > buffer->numElements )
721 {
722 // If this is called from a script we raise a script exception
723 asIScriptContext *ctx = asGetActiveContext();
724 if (ctx)
725 ctx->SetException("Index out of bounds");
726 return;
727 }
728
729 // Cap count to the end of the array
730 if (start + count > buffer->numElements)
731 count = buffer->numElements - start;
732
733 // Destroy the elements that are being removed
734 Destruct(buffer, start, start + count);
735
736 // Compact the elements
737 // As objects in arrays of objects are not stored inline, it is safe to use memmove here
738 // since we're just copying the pointers to objects and not the actual objects.
739 memmove(buffer->data + start*elementSize, buffer->data + (start + count)*elementSize, (buffer->numElements - start - count)*elementSize);
740 buffer->numElements -= count;
741}
742
743// Internal
744void CScriptArray::Resize(int delta, asUINT at)

Callers 1

Calls 2

SetExceptionMethod · 0.80
DestructFunction · 0.50

Tested by

no test coverage detected