int main() { node* headptr;//保存第一个节点的地址 createlist(&headptr); insert(&headptr, 10, 2);//无效位置,会更正成末尾 insert(&headptr, 20, 0);//20,10 insert(&headptr, 30, 2);//20,10,30 insert(&headptr, 40, 1);//20,40,10,30 insert(&headptr, 50, 8);//无效位置,会更正成末尾 travel(headptr); printf("剩余%d个数据\n", listsize(headptr)); int n = find(headptr, 10); printf("查找10在第%d个节点\n", n); erase(&headptr, n); travel(headptr); n = find(headptr, 10); printf("查找10在第%d个节点\n", n); erase(&headptr, n); travel(headptr); setdata(headptr, 10, 100); setdata(headptr, 2, 99); travel(headptr); clear(&headptr); printf("剩余%d个数据\n", listsize(headptr)); return 0; }
void unFilterListCtrl::UpdateBoxes() { // get my size wxSize mysize = GetClientSize(); // get leftmost listitem position wxPoint itempos; List->GetItemPosition(0,itempos); // update sizes list EditSizes.resize( List->GetColumnCount() ); // get list border wxRect rb,rl; List->GetItemRect(0,rb,wxLIST_RECT_BOUNDS); List->GetItemRect(0,rl,wxLIST_RECT_LABEL); dword listborder = rl.GetX() - rb.GetX(); // update sizes dword width, acc = 0, y = 0; for(dword i=0; i<EditSizes.size(); ++i) { width = List->GetColumnWidth(i); // stretch first box to left edge if( i == 0 ) { width += listborder; acc -= listborder; } EditSizes[i].SetX(acc+itempos.x); EditSizes[i].SetY(y); EditSizes[i].SetWidth(width); EditSizes[i].SetHeight(-1); acc += width; } // create new editboxes if neccessary if( EditSizes.size() > EditBoxes.size() ) { EditBoxes.resize( EditSizes.size(), NULL ); for( dword i=0; i<EditBoxes.size(); ++i ) { if( EditBoxes[i] == NULL ) { wxTextCtrl* box = new wxTextCtrl( EditPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); wxListItem item; List->GetColumn(i,item); wxString text = wxT("\""); text.Append( List->Table->GetHeader() AT(i).GetCaption().wx_str() ); text.Append( wxT("\" filter") ); box->SetToolTip( text ); //wxString text; //text.Printf("%d",i); //EditBoxes[i]->WriteText(text); EditBoxes[i] = box; } } } // stretch last box to right edge if( !EditSizes.empty() ) { wxRect lastbox = EditSizes.back(); int lastpos = lastbox.GetX() + lastbox.GetWidth(); //wxLogMessage("%d %d",lastpos, mysize.GetWidth()); if( lastpos < mysize.GetWidth() ) { EditSizes.back().SetWidth( lastbox.GetWidth() + (mysize.GetWidth() - lastpos) ); } } // update editbox coords for( dword i=0; i<EditBoxes.size(); ++i ) { //wxLogMessage("%d %d",itempos.x,ColumnX[i]); EditBoxes[i]->SetSize(EditSizes[i].GetSize()); EditBoxes[i]->Move(EditSizes[i].GetPosition()); } // set list size wxRect listsize( mysize ); wxRect panelsize( mysize ); if( !EditBoxes.empty() ) { wxRect boxsize( EditBoxes[0]->GetBestSize() ); panelsize.SetHeight( boxsize.GetHeight() ); listsize.SetY( panelsize.GetHeight() ); listsize.SetHeight( mysize.GetHeight()-panelsize.GetHeight() ); } List->SetSize(listsize.GetSize()); List->Move(listsize.GetPosition()); EditPanel->SetSize(panelsize.GetSize()); EditPanel->Move(panelsize.GetPosition()); // fix editbox flicker for( dword i=0; i<EditBoxes.size(); ++i ) { EditBoxes[i]->ClearBackground(); EditBoxes[i]->Refresh(); } }
void pushback(node** headptraddr, T data){ insert(headptraddr,data,listsize(*headptraddr)); }