Posts

java - Bst tree delete() method doesnt work -

i implementing binary search tree , wondering, why delete() method doesn't work... findmin() method work, have tested out far. type in key, doesn't exist in 3 , right exception, whenever type in key, existing, doesn't remove node three... here code far: import java.util.nosuchelementexception; public class bst { node root; node head; node tail; public bst(){ root = null; } public void insert (node root, int key){ node newnode=new node(key); if(root==null){ root=newnode; } if(key<=root.getkey()){ if (root.getleft()!=null){ insert(root.getleft(), key); } else{ root.setleft(newnode); } } if (key>=root.getkey()){ if (root.getright()!=null){ insert(root.getright(),key); } else{ root.setright(newnode); } } } public void printtree(node root){ if (root==null) return; printtree(root.getleft()); ...

javascript - How to set request body and params on $resource POST -

i'm attempting pass data in request body , request parameter angular $resource call. below click handler controller , service calls: controller.js: vm.setlimit = function(limit) { var data = { activity: 'point_limit', limit: limit }; playersservice.setplayerlimit({ playerid: playerid, data }); }; service.js: angular.module('gameapp') .factory('playersservice', ['$resource', function($resource) { var base = '/api/players/:playerid/'; return $resource(base, {}, { getplayerinfo: {method: 'get', url: base + 'playerinfo'}, setplayerlimit: {method: 'post', url: base + 'playerlimit'} }); }]); getplayerinfo works, setplayerlimit not because, reason, not being passed playerid . playersservice.setplayerlimit should take 4 parameters in order: (request parameters, request body, success callback, error callback) modify code as...

android - How to destroy a fragment and then create a new? -

i have fragment plays videos, start application , goes perfectly, when press button , select video file play, view not play video. videoactivity @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_video); a=this; th = thread.currentthread(); // obter url vÍdeo bundle extras = getintent().getextras(); if (extras != null) _videourl = extras.getstring("caminho_arquivo"); if (savedinstancestate == null) { getfragmentmanager().begintransaction() .add(r.id.container, new placeholderfragment()).commit(); } } public static class placeholderfragment extends fragment { static private final int buffer_size = 700;// mb static private final int num_files = 20;// count files in cache dir public placeholderfragment() {} @override public view oncreateview(layoutinflater inflater, viewgroup conta...

android - Image rollover issue -

i implemented images rollover css using code: .content3{ background-image:url(../img/tablet2.jpg); background-repeat:no-repeat; border:5px solid #fa8072; border-radius:5px; width:220px; height:200px; margin:0 auto; } .content3:hover{ background-image:url(../img/servizibis.png); background-repeat:no-repeat; border:5px solid #fa8072; border-radius:5px; width:220px; height:200px; margin:0 auto; } this works fine on website desktop version doesn't work on responsive version on ipad , smartphone android. exist solution javascript or jquery code?

Really fast word ngram vectorization in R -

edit: new package text2vec excellent, , solves problem (and many others) well. text2vec on cran text2vec on github vignette illustrates ngram tokenization i have pretty large text dataset in r, i've imported character vector: #takes 15 seconds system.time({ set.seed(1) samplefun <- function(n, x, collapse){ paste(sample(x, n, replace=true), collapse=collapse) } words <- sapply(rpois(10000, 3) + 1, samplefun, letters, '') sents1 <- sapply(rpois(1000000, 5) + 1, samplefun, words, ' ') }) i can convert character data bag-of-words representation follows: library(stringi) library(matrix) tokens <- stri_split_fixed(sents1, ' ') token_vector <- unlist(tokens) bagofwords <- unique(token_vector) n.ids <- sapply(tokens, length) <- rep(seq_along(n.ids), n.ids) j <- match(token_vector, bagofwords) m <- sparsematrix(i=i, j=j, x=1l) colnames(m) <- bagofwords so r can vectorize 1,000,000 million short sentenc...

html5 - A div containing images disappears on iphone -

Image
i have tried searching solution everywhere not find it. hence posting request here. we have website built on php code-ignition mvc framework, issue html rendering on various devices imo. section on bottom of rendered page disappears on iphone, renders fine on ipad , normal browser. have saved page html , able reproduce via chrome devices (from developer tools), switching on various devices. the designer helped create these templates not accessible anymore, not able further help. suspect css issue. website uses twitter-bootstrap. screenshots: normal browser & iphone redering comparison: (the div in question marked arrow) i have looked view source , div in question appears on both versions in html source: <div class="button-holders button-overlay" id="button_holder"> <div class="col-sm-3 col-xs-3 noway" id="noway" style="display: block;"> <a id="noway1" style="cursor:point...

fortran90 - Have a function in fortran return a reference that can be placed on the left-hand-side of an assignment -

as stated in title, want directly modify data access through pointer retrieved function. having reference returned function appearing on l.h.s. of assignment(=) no issue in c++ following minimal example in fortran errors out: module test_mod implicit none integer, target :: a=1, b=2, c=3 ! member variables contains function get(i) integer, pointer :: integer, intent(in) :: select case (i) case (1) => case (2) => b case (3) => c end select end function end module test_mod program test use test_mod implicit none integer, pointer :: i_p !> prints out 1 2 3 print*, get(1), get(2), get(3) !> want error !> error: 'get' @ (1) not variable get(2) = 5 !> works not want i_p => get(2) i_p = 5 end program test is there way accomplish behaviour; maybe i'm missing attributes? bypass writing setter routines such as set(i,value) since should mimic appearan...