Esempio n. 1
0
IO_METHOD(IoSeq, replaceMap)
{
	/*doc Sequence replaceMap(aMap)
	In the receiver, the keys of aMap replaced with its values. Returns self.
	*/

	IoMap *map = IoMessage_locals_mapArgAt_(m, locals, 0);
	UArray *ba = DATA(self);

	IO_ASSERT_NOT_SYMBOL(self);

	PHASH_FOREACH(IoMap_rawHash(map), k, v,
		{
		IoSymbol *subSeq = k;
		IoSymbol *otherSeq = v;

		if (ISSEQ(otherSeq))
		{
			UArray_replace_with_(ba, DATA(subSeq), DATA(otherSeq));
		}
		else
		{
			IoState_error_(IOSTATE, m,
							"argument 0 to method '%s' must be a Map with Sequence values, not '%s'",
							CSTRING(IoMessage_name(m)), IoObject_name(otherSeq));
		}
		}
	);
Esempio n. 2
0
IO_METHOD(IoSeq, replaceSeq)
{
	/*doc Sequence replaceSeq(aSequence, anotherSequence)
	Returns a new Sequence with all occurances of aSequence
	replaced with anotherSequence in the receiver. Returns self.
	*/

	IoSeq *subSeq   = IoMessage_locals_seqArgAt_(m, locals, 0);
	IoSeq *otherSeq = IoMessage_locals_seqArgAt_(m, locals, 1);
	IO_ASSERT_NOT_SYMBOL(self);
	UArray_replace_with_(DATA(self), DATA(subSeq), DATA(otherSeq));
	return self;
}
Esempio n. 3
0
BASEKIT_API void UArray_remove_(UArray *self, const UArray *a1)
{
    UArray blank = UArray_stackAllocedEmptyUArray();
    UArray_replace_with_(self, a1, &blank);
}
Esempio n. 4
0
BASEKIT_API void UArray_replaceCString_withCString_(UArray *self, const char *s1, const char *s2)
{
    UArray a1 = UArray_stackAllocedWithCString_((char *)s1);
    UArray a2 = UArray_stackAllocedWithCString_((char *)s2);
    UArray_replace_with_(self, &a1, &a2);
}