ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {

        ListNode* prehead1 = l1;
        ListNode* prehead2 = l2;
        ListNode* prev1 = NULL;
        ListNode* prev2 = NULL;

        l1 = ReverseList(l1);
        l2 = ReverseList(l2);

    return ReverseList( addTwoNumbersRev(l1, l2));
    }
예제 #2
0
파일: main.cpp 프로젝트: duansy2002/Linux-C
int main()
{
	int a[10]={1,2,3,4,5,6,7,8,9,10};
	//创建链表
	LinkInfo *L=CreateInfoFromArray(a,10);
	//1-单链表反转
	ReverseList(L);
	ReverseList(L);
	//2-倒数第K个的验证
	node* last[11];
	for(int i=0;i<11;i++)
		last[i]=lastK(*L,i+1);
	//3-中间元素
	node* mid=FinMid(*L);
	//4-删除无头结点
	//DelNoHead(L->head->next);
	//5-有序链表合并
	int a1[5]={5,5,4,3,1};
	int b1[3]={7,4,2};
	LinkInfo *p=CreateInfoFromArray(a1,0);//测试案例: 1-p,q 递增 2-p,q递减 3-p为空 4-q为空 5-p,q均为空
	LinkInfo *q=CreateInfoFromArray(b1,3);
	MergeList(p,q);
	//6-判断链表是否有环(并返回环的起点node*)
	LinkInfo *circle=CreateInfoFromArray(a,6);//测试:有环、无环、空链表
	node *nocross=IfCircle(circle->head);
	circle->tail->next=circle->head->next->next->next;//构造一个环
	node *cross=IfCircle(circle->head);
	//7+8-两个单链表是否相交?求交点
	LinkInfo *A=CreateInfoFromArray(a1,5);//测试:1-不交叉 2- 交叉 3- 空链表
	LinkInfo *B=CreateInfoFromArray(b1,3);
	node *nointersection1=Intersection1(A->head,B->head);
	node *nointersection2=Intersection2(A->head,B->head);//NULL
	B->tail->next=A->head->next->next->next;//设置交叉点在4
	node *intersection1=Intersection1(A->head,B->head);
	node *intersection2=Intersection1(A->head,B->head);// 4
	//9-单链表排序
	int s[10]={54,41,32,1,6,4,54,32,658,2};
	LinkInfo *linksort=CreateInfoFromArray(s,10);
	LinkSortQ(linksort,0);
	//10-删除重复元素
	DelRepeated(linksort);
	//11-拆分链表
	LinkInfo *odd=CreateLinkInfo();
	LinkInfo *even=CreateLinkInfo();
	SplitList(L,odd,even);
	//12-大整数加法
	char numa[]="-7987465413213546465461111111111";
	char numb[]="-574968465216352468749611";
	char* result=BigNum(numa,numb);
	return 0;
}
예제 #3
0
void main()
{
    int choice = 7;
    Listinit();
    while(1) 
    {
        printf("LinkedList Operations:\n");
        printf("1. Insert Head\n2. Display\n3. Middle\n4. Reverse List\n5. ReverseRecursiveList\n7. Exit\n");
        printf("Enter your choice : ");
        scanf(" %d", &choice);
        switch (choice)
        {
            case 1  :   insertRoot();
            break;
            case 2  :   display();
            break;
            case 3  :   MiddleList();
            break;
            case 4  :   ReverseList();
            break;
            case 5  :   ReverseRecursiveList(&root);
            break;
            default :
            exit(0);
        }
    }
}
예제 #4
0
파일: main.cpp 프로젝트: zhenl010/zhenl010
int main() {
  int range_size = 8;
  int reset_num = 6;
  Node* list_one = new Node(range_size+rand()%range_size);
  while(0<list_one->val) {
    Node* new_node = new Node(list_one->val-rand()%reset_num);
    new_node->next = list_one;
    list_one = new_node;
  }
  CoutList(list_one);
  Node* list_two = new Node(range_size+rand()%range_size);
  while(0<list_two->val) {
    Node* new_node = new Node(list_two->val-rand()%reset_num);
    new_node->next = list_two;
    list_two = new_node;
  }
  CoutList(list_two);

  Node* merged = MergeSortedLists(list_one, list_two);
  CoutList(merged);
  Node* reversed = ReverseList(merged);
  CoutList(reversed);
  Node* sorted = MergeSort(reversed);
  CoutList(sorted);

  return 0;
}
void checkPalindrome(node_t **headPtr,int mid){
	node_t *link=NULL;
	node_t *slowPtr,*fastPtr;
	
	ReverseList(headPtr,mid);
	
	//Comparing.
	//
	link = *headPtr;
	slowPtr = fastPtr = link;
	
	//push a link forward.
	if(lengthOfList(*headPtr)%2!=0){
		link=link->next;
	}
	
	while(fastPtr!=NULL){
		fastPtr = fastPtr->next;
		if(fastPtr!=NULL&&fastPtr->next!=NULL){
			fastPtr=fastPtr->next;
			slowPtr=slowPtr->next;
		}
		
	}
	
	slowPtr = slowPtr->next;
	
	while(slowPtr!=NULL){
		if(slowPtr->val!=link->val){
			printf("Not a Palindrome");
			break;
		}
		slowPtr=slowPtr->next;
		link=link->next;
	}
	if(slowPtr==NULL){
		printf("Palindrome");
	}
	
	
	
	//reversing it back.
	ReverseList(headPtr,mid);
	
}
예제 #6
0
int main(void)
{
    node** pHead = NULL;
	//CreateNode(pHead);
    node* pEnd = ReverseList(*pHead);
	if(pEnd != NULL) {
        pEnd->m_pNext = NULL;
	}
	//TestPrintNode(ReversedNode);
    return 0;
}
예제 #7
0
파일: main.cpp 프로젝트: nilzyj/test
int main(void)
{
    Node *head;
    head=CreatList();
    printf("链表逆置前的数据:\n");
    PrintList(head);
    head=ReverseList(head);
    printf("链表逆置后的数据:\n");
    PrintList(head);
    return 0;
}
예제 #8
0
파일: exercise.c 프로젝트: wanghan/my_code
void TestReverseList() {
	// make list 1
	List l1 = NULL;
	l1 = MakeArrayStackEmpty(l1);
	Position curl1 = l1;
	for (int i = 0; i < 1; ++i) {
		curl1 = Insert(i * 3, l1, curl1);
	}
	PrintList(l1);
	ReverseList(l1);
	PrintList(l1);
}
예제 #9
0
파일: sw_top.c 프로젝트: Hilx/SynADT
int main()
{
	init_platform();

	print("Hello World\n\r");



	int *hdList;
	int i,j;
	for(i =0; i < 21; i++){
		SysAlloc_init();

		int log2ListSize = i;
		int *hdList = NULL;

		putnum(log2ListSize);
		print(" ");

		XIo_Out32(COUNTER_BASE + 4 * 1, START);
		hdList = RandListGen(log2ListSize, hdList);
		XIo_Out32(COUNTER_BASE + 4 * 1, STOP);

		XIo_Out32(COUNTER_BASE + 4 * 2, START);
		hdList = ReverseList(hdList);
		XIo_Out32(COUNTER_BASE + 4 * 2, STOP);

		XIo_Out32(COUNTER_BASE + 4 * 3, START);
		hdList = DeleteList(hdList);
		XIo_Out32(COUNTER_BASE + 4 * 3, STOP);



		for(j = 1; j <4; j++){
			// read counter result back
			int high_value = XIo_In32(COUNTER_BASE + 4 * (j + 8));
			if(high_value != 0){
				putnum(high_value);
			}
			putnum(XIo_In32(COUNTER_BASE + 4 * j));
			print(" ");

			// reset counter
			XIo_Out32(COUNTER_BASE + 4 * j,RESET);
		}
		print("\n");
	}

	print("\n all done\n");

	cleanup_platform();
	return 0;
}
예제 #10
0
void    FCSetNml( void ) {
//==================

// Set NAMELIST format.

    call_handle handle;
    sym_id      nl;
    grp_entry   *ge;

    NmlSpecified = TRUE;
    handle = InitCall( RT_SET_NML );
    nl = GetPtr();
    ReverseList( &nl->nl.group_list );
    ge = nl->nl.group_list;
    while( ge != NULL ) {
        CGAddParm( handle, SymAddr( ge->sym ), TY_POINTER );
        ge = ge->link;
    }
    ReverseList( &nl->nl.group_list );
    CGAddParm( handle, CGBackName( nl->nl.address, TY_POINTER ), TY_POINTER );
    CGDone( CGCall( handle ) );
}
예제 #11
0
node* ReverseList(node* pHead)
{
    node* pNode = pHead;
    if(pNode != NULL) {
        node* pPrev = pNode->m_pNext;
        if(pPrev != NULL) {
            pPrev = ReverseList(pPrev);
            pPrev->m_pNext = pNode;
        } else {
            ReversedNode = pNode;
        }
    }
    return pNode;	
}
예제 #12
0
    ListNode *reverseKGroup(ListNode *head, int k) {
        if(head == NULL || k==1){
            return head;
        }
       	auto node = head;
        for(int i=0;i<k;++i){
            if(!node) return head;
            node = node->next;
        }
		//递归实现
        auto new_head = ReverseList(head, node);	
        head->next = reverseKGroup(node, k);
        return new_head;
    }
예제 #13
0
int main()
{
	int arrData[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
	Node* pHead = NULL;

	pHead = CreateList(arrData, sizeof(arrData) / sizeof(int));
	OutputList(pHead);

	pHead = ReverseList(pHead);
	OutputList(pHead);

	pHead = DestroyList(pHead);

	return 0;
}
예제 #14
0
int main()
{
	struct Node *n1;

	n1 = AddStartNode(30);
	n1 = AddNodeAtBeg(n1, 20);
	n1 = AddNodeAtBeg(n1, 10);
	AddNodeAtEnd(n1, 50);
	AddNodeAtEnd(n1, 60);
	AddNodeAtEnd(n1, 70);
	AddNodeAtPos(n1, 40, 4);
	PrintList(n1);
	n1 = DeleteNodeAtPos(n1, 3);
	PrintList(n1);
	n1 = DeleteNodeByVal(n1, 60);
	PrintList(n1);
	n1 = ReverseList(n1);
	PrintList(n1);
	
	//printf("%d",n1->data);
	
	return 0;
}
예제 #15
0
	RenderedSubtitle* Renderer::Lookup(const Subtitle* s, const CSize& vs, const CRect& vr)
	{
		m_sra.UpdateTarget(vs, vr);

		if(s->m_text.IsEmpty()) {
			return NULL;
		}

		CRect spdrc = s->m_frame.reference == _T("video") ? vr : CRect(CPoint(0, 0), vs);

		if(spdrc.IsRectEmpty()) {
			return NULL;
		}

		RenderedSubtitle* rs = NULL;

		if(m_rsc.Lookup(s->m_name, rs)) {
			if(!s->m_animated && rs->m_spdrc == spdrc) {
				return rs;
			}

			m_rsc.Invalidate(s->m_name);
		}

		const Style& style = s->m_text.GetHead().style;

		Size scale;

		scale.cx = (float)spdrc.Width() / s->m_frame.resolution.cx;
		scale.cy = (float)spdrc.Height() / s->m_frame.resolution.cy;

		CRect frame;

		frame.left = (int)(64.0f * (spdrc.left + style.placement.margin.l * scale.cx) + 0.5);
		frame.top = (int)(64.0f * (spdrc.top + style.placement.margin.t * scale.cy) + 0.5);
		frame.right = (int)(64.0f * (spdrc.right - style.placement.margin.r * scale.cx) + 0.5);
		frame.bottom = (int)(64.0f * (spdrc.bottom - style.placement.margin.b * scale.cy) + 0.5);

		CRect clip;

		if(style.placement.clip.l == -1) {
			clip.left = 0;
		} else {
			clip.left = (int)(spdrc.left + style.placement.clip.l * scale.cx);
		}
		if(style.placement.clip.t == -1) {
			clip.top = 0;
		} else {
			clip.top = (int)(spdrc.top + style.placement.clip.t * scale.cy);
		}
		if(style.placement.clip.r == -1) {
			clip.right = vs.cx;
		} else {
			clip.right = (int)(spdrc.left + style.placement.clip.r * scale.cx);
		}
		if(style.placement.clip.b == -1) {
			clip.bottom = vs.cy;
		} else {
			clip.bottom = (int)(spdrc.top + style.placement.clip.b * scale.cy);
		}

		clip.left = max(clip.left, 0);
		clip.top = max(clip.top, 0);
		clip.right = min(clip.right, vs.cx);
		clip.bottom = min(clip.bottom, vs.cy);

		scale.cx *= 64;
		scale.cy *= 64;

		bool vertical = s->m_direction.primary == _T("down") || s->m_direction.primary == _T("up");

		// create glyph paths

		WCHAR c_prev = 0, c_next;

		CAutoPtrList<Glyph> glyphs;

		POSITION pos = s->m_text.GetHeadPosition();
		while(pos) {
			const Text& t = s->m_text.GetNext(pos);

			LOGFONT lf;
			memset(&lf, 0, sizeof(lf));
			lf.lfCharSet = DEFAULT_CHARSET;
			_tcscpy_s(lf.lfFaceName, CString(t.style.font.face));
			lf.lfHeight = (LONG)(t.style.font.size * scale.cy + 0.5);
			lf.lfWeight = (LONG)(t.style.font.weight + 0.5);
			lf.lfItalic = !!t.style.font.italic;
			lf.lfUnderline = !!t.style.font.underline;
			lf.lfStrikeOut = !!t.style.font.strikethrough;
			lf.lfOutPrecision = OUT_TT_PRECIS;
			lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
			lf.lfQuality = ANTIALIASED_QUALITY;
			lf.lfPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE;

			FontWrapper* font = m_fc.Create(m_hDC, lf);

			if(!font) {
				_tcscpy_s(lf.lfFaceName, _T("Arial"));

				font = m_fc.Create(m_hDC, lf);
				if(!font) {
					ASSERT(0);
					continue;
				}
			}

			HFONT hOldFont = SelectFont(m_hDC, *font);

			const TEXTMETRIC& tm = font->GetTextMetric();

			for(LPCWSTR c = t.str; *c; c++) {
				CAutoPtr<Glyph> g(DNew Glyph());

				g->c = *c;
				g->style = t.style;
				g->scale = scale;
				g->vertical = vertical;
				g->font = font;

				c_next = !c[1] && pos ? c_next = s->m_text.GetAt(pos).str[0] : c[1];
				Arabic::Replace(g->c, c_prev, c_next);
				c_prev = c[0];

				CSize extent;
				GetTextExtentPoint32W(m_hDC, &g->c, 1, &extent);
				ASSERT(extent.cx >= 0 && extent.cy >= 0);

				if(vertical) {
					g->spacing = (int)(t.style.font.spacing * scale.cy + 0.5);
					g->ascent = extent.cx / 2;
					g->descent = extent.cx - g->ascent;
					g->width = extent.cy;

					// TESTME
					if(g->c == Text::SP) {
						g->width /= 2;
					}
				} else {
					g->spacing = (int)(t.style.font.spacing * scale.cx + 0.5);
					g->ascent = tm.tmAscent;
					g->descent = tm.tmDescent;
					g->width = extent.cx;
				}

				if(g->c == Text::LSEP) {
					g->spacing = 0;
					g->width = 0;
					g->ascent /= 2;
					g->descent /= 2;
				} else {
					GlyphPath* path = m_gpc.Create(m_hDC, font, g->c);
					if(!path) {
						ASSERT(0);
						continue;
					}
					g->path = *path;
				}

				glyphs.AddTail(g);
			}

			SelectFont(m_hDC, hOldFont);
		}

		// break glyphs into rows

		CAutoPtrList<Row> rows;
		CAutoPtr<Row> row;

		pos = glyphs.GetHeadPosition();
		while(pos) {
			CAutoPtr<Glyph> g = glyphs.GetNext(pos);
			if(!row) {
				row.Attach(DNew Row());
			}
			WCHAR c = g->c;
			row->AddTail(g);
			if(c == Text::LSEP || !pos) {
				rows.AddTail(row);
			}
		}

		// kerning

		if(s->m_direction.primary == _T("right")) { // || s->m_direction.primary == _T("left")
			for(POSITION rpos = rows.GetHeadPosition(); rpos; rows.GetNext(rpos)) {
				Row* r = rows.GetAt(rpos);

				POSITION gpos = r->GetHeadPosition();
				while(gpos) {
					Glyph* g1 = r->GetNext(gpos);
					if(!gpos) {
						break;
					}

					Glyph* g2 = r->GetAt(gpos);
					if(g1->font != g2->font || !g1->style.font.kerning || !g2->style.font.kerning) {
						continue;
					}

					if(int size = g1->font->GetKernAmount(g1->c, g2->c)) {
						g2->path.MovePoints(CPoint(size, 0));
						g2->width += size;
					}
				}
			}
		}

		// wrap rows

		if(s->m_wrap == _T("normal") || s->m_wrap == _T("even")) {
			int maxwidth = abs((int)(vertical ? frame.Height() : frame.Width()));
			int minwidth = 0;

			for(POSITION rpos = rows.GetHeadPosition(); rpos; rows.GetNext(rpos)) {
				Row* r = rows.GetAt(rpos);

				POSITION brpos = NULL;

				if(s->m_wrap == _T("even")) {
					int fullwidth = 0;

					for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
						const Glyph* g = r->GetAt(gpos);

						fullwidth += g->width + g->spacing;
					}

					fullwidth = abs(fullwidth);

					if(fullwidth > maxwidth) {
						maxwidth = fullwidth / ((fullwidth / maxwidth) + 1);
						minwidth = maxwidth;
					}
				}

				int width = 0;

				for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
					const Glyph* g = r->GetAt(gpos);

					width += g->width + g->spacing;

					if(brpos && abs(width) > maxwidth && g->c != Text::SP) {
						row.Attach(DNew Row());
						POSITION next = brpos;
						r->GetNext(next);
						do {
							row->AddHead(r->GetPrev(brpos));
						} while(brpos);
						rows.InsertBefore(rpos, row);
						while(!r->IsEmpty() && r->GetHeadPosition() != next) {
							r->RemoveHeadNoReturn();
						}
						g = r->GetAt(gpos = next);
						width = g->width + g->spacing;
					}

					if(abs(width) >= minwidth) {
						if(g->style.linebreak == _T("char")
								|| g->style.linebreak == _T("word") && g->c == Text::SP) {
							brpos = gpos;
						}
					}
				}
			}
		}

		// trim rows

		for(POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos)) {
			Row* r = rows.GetAt(pos);

			while(!r->IsEmpty() && r->GetHead()->c == Text::SP) {
				r->RemoveHead();
			}

			while(!r->IsEmpty() && r->GetTail()->c == Text::SP) {
				r->RemoveTail();
			}
		}

		// calc fill width for each glyph

		CAtlList<Glyph*> glypsh2fill;
		int fill_id = 0;
		int fill_width = 0;

		for(POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos)) {
			Row* r = rows.GetAt(pos);

			POSITION gpos = r->GetHeadPosition();
			while(gpos) {
				Glyph* g = r->GetNext(gpos);

				if(!glypsh2fill.IsEmpty() && fill_id && (g->style.fill.id != fill_id || !pos && !gpos)) {
					int w = (int)(g->style.fill.width * fill_width + 0.5);

					while(!glypsh2fill.IsEmpty()) {
						Glyph* g = glypsh2fill.RemoveTail();
						fill_width -= g->width;
						g->fill = w - fill_width;
					}

					ASSERT(glypsh2fill.IsEmpty());
					ASSERT(fill_width == 0);

					glypsh2fill.RemoveAll();
					fill_width = 0;
				}

				fill_id = g->style.fill.id;

				if(g->style.fill.id) {
					glypsh2fill.AddTail(g);
					fill_width += g->width;
				}
			}
		}

		// calc row sizes and total subtitle size

		CSize size(0, 0);

		if(s->m_direction.secondary == _T("left") || s->m_direction.secondary == _T("up")) {
			ReverseList(rows);
		}

		for(POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos)) {
			Row* r = rows.GetAt(pos);

			if(s->m_direction.primary == _T("left") || s->m_direction.primary == _T("up")) {
				ReverseList(*r);
			}

			int w = 0, h = 0;

			r->width = 0;

			for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
				const Glyph* g = r->GetAt(gpos);

				w += g->width;
				if(gpos) {
					w += g->spacing;
				}
				h = max(h, g->ascent + g->descent);

				r->width += g->width;
				if(gpos) {
					r->width += g->spacing;
				}
				r->ascent = max(r->ascent, g->ascent);
				r->descent = max(r->descent, g->descent);
				r->border = max(r->border, g->GetBackgroundSize());
			}

			for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
				Glyph* g = r->GetAt(gpos);
				g->row_ascent = r->ascent;
				g->row_descent = r->descent;
			}

			if(vertical) {
				size.cx += h;
				size.cy = max(size.cy, w);
			} else {
				size.cx = max(size.cx, w);
				size.cy += h;
			}
		}

		// align rows and calc glyph positions

		rs = DNew RenderedSubtitle(spdrc, clip);

		CPoint p = GetAlignPoint(style.placement, scale, frame, size);
		CPoint org = GetAlignPoint(style.placement, scale, frame);

		// collision detection

		if(!s->m_animated) {
			int tlb = !rows.IsEmpty() ? rows.GetHead()->border : 0;
			int brb = !rows.IsEmpty() ? rows.GetTail()->border : 0;

			CRect r(p, size);
			m_sra.GetRect(r, s, style.placement.align, tlb, brb);
			org += r.TopLeft() - p;
			p = r.TopLeft();
		}

		CRect subrect(p, size);

		// continue positioning

		for(POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos)) {
			Row* r = rows.GetAt(pos);

			CSize rsize;
			rsize.cx = rsize.cy = r->width;

			if(vertical) {
				p.y = GetAlignPoint(style.placement, scale, frame, rsize).y;

				for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
					CAutoPtr<Glyph> g = r->GetAt(gpos);
					g->tl.x = p.x + (int)(g->style.placement.offset.x * scale.cx + 0.5) + r->ascent - g->ascent;
					g->tl.y = p.y + (int)(g->style.placement.offset.y * scale.cy + 0.5);
					p.y += g->width + g->spacing;
					rs->m_glyphs.AddTail(g);
				}

				p.x += r->ascent + r->descent;
			} else {
				p.x = GetAlignPoint(style.placement, scale, frame, rsize).x;

				for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
					CAutoPtr<Glyph> g = r->GetAt(gpos);
					g->tl.x = p.x + (int)(g->style.placement.offset.x * scale.cx + 0.5);
					g->tl.y = p.y + (int)(g->style.placement.offset.y * scale.cy + 0.5) + r->ascent - g->ascent;
					p.x += g->width + g->spacing;
					rs->m_glyphs.AddTail(g);
				}

				p.y += r->ascent + r->descent;
			}
		}

		// bkg, precalc style.placement.path, transform

		pos = rs->m_glyphs.GetHeadPosition();
		while(pos) {
			Glyph* g = rs->m_glyphs.GetNext(pos);
			g->CreateBkg();
			g->CreateSplineCoeffs(spdrc);
			g->Transform(org, subrect);
		}

		// merge glyphs (TODO: merge 'fill' too)

		Glyph* g0 = NULL;

		pos = rs->m_glyphs.GetHeadPosition();
		while(pos) {
			POSITION cur = pos;

			Glyph* g = rs->m_glyphs.GetNext(pos);

			CRect r = g->bbox + g->tl;

			int size = (int)(g->GetBackgroundSize() + 0.5);
			int depth = (int)(g->GetShadowDepth() + 0.5);

			r.InflateRect(size, size);
			r.InflateRect(depth, depth);

			r.left >>= 6;
			r.top >>= 6;
			r.right = (r.right + 32) >> 6;
			r.bottom = (r.bottom + 32) >> 6;

			if((r & clip).IsRectEmpty()) { // clip
				rs->m_glyphs.RemoveAt(cur);
			} else if(g0 && g0->style.IsSimilar(g->style)) { // append
				CPoint o = g->tl - g0->tl;

				g->path.MovePoints(o);

				g0->path.types.Append(g->path.types);
				g0->path.points.Append(g->path.points);

				g->path_bkg.MovePoints(o);

				g0->path_bkg.types.Append(g->path_bkg.types);
				g0->path_bkg.points.Append(g->path_bkg.points);

				g0->bbox |= g->bbox + o;

				rs->m_glyphs.RemoveAt(cur);
			} else { // leave alone
				g0 = g;
			}
		}

		// rasterize

		pos = rs->m_glyphs.GetHeadPosition();
		while(pos) {
			rs->m_glyphs.GetNext(pos)->Rasterize();
		}

		// cache

		m_rsc.Add(s->m_name, rs);

		m_fc.Flush();

		return rs;
	}